cipconnectionobjecttest.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*******************************************************************************
  2. * Copyright (c) 2017, Rockwell Automation, Inc.
  3. * All rights reserved.
  4. *
  5. ******************************************************************************/
  6. #include <CppUTest/TestHarness.h>
  7. #include <stdint.h>
  8. #include <string.h>
  9. extern "C" {
  10. #include "cipconnectionobject.h"
  11. }
  12. TEST_GROUP(CipConnectionObject) {
  13. };
  14. TEST(CipConnectionObject, StateNonExistent) {
  15. CipConnectionObject connection_object = { 0 };
  16. connection_object.state = 0;
  17. ConnectionObjectState state = GetConnectionObjectState(&connection_object);
  18. CHECK_EQUAL(kConnectionObjectStateNonExistent, state);
  19. }
  20. TEST(CipConnectionObject, StateConfiguring) {
  21. CipConnectionObject connection_object = { 0 };
  22. connection_object.state = 1;
  23. ConnectionObjectState state = GetConnectionObjectState(&connection_object);
  24. CHECK_EQUAL(kConnectionObjectStateConfiguring, state);
  25. }
  26. TEST(CipConnectionObject, StateWaitingForConnectionID) {
  27. CipConnectionObject connection_object = { 0 };
  28. connection_object.state = 2;
  29. ConnectionObjectState state = GetConnectionObjectState(&connection_object);
  30. CHECK_EQUAL(kConnectionObjectStateWaitingForConnectionID, state);
  31. }
  32. TEST(CipConnectionObject, StateEstablished) {
  33. CipConnectionObject connection_object = { 0 };
  34. connection_object.state = 3;
  35. ConnectionObjectState state = GetConnectionObjectState(&connection_object);
  36. CHECK_EQUAL(kConnectionObjectStateEstablished, state);
  37. }
  38. TEST(CipConnectionObject, StateTimedOut) {
  39. CipConnectionObject connection_object = { 0 };
  40. connection_object.state = 4;
  41. ConnectionObjectState state = GetConnectionObjectState(&connection_object);
  42. CHECK_EQUAL(kConnectionObjectStateTimedOut, state);
  43. }
  44. TEST(CipConnectionObject, StateDeferredDelete) {
  45. CipConnectionObject connection_object = { 0 };
  46. connection_object.state = 5;
  47. ConnectionObjectState state = GetConnectionObjectState(&connection_object);
  48. CHECK_EQUAL(kConnectionObjectStateDeferredDelete, state);
  49. }
  50. TEST(CipConnectionObject, StateClosing) {
  51. CipConnectionObject connection_object = { 0 };
  52. connection_object.state = 6;
  53. ConnectionObjectState state = GetConnectionObjectState(&connection_object);
  54. CHECK_EQUAL(kConnectionObjectStateClosing, state);
  55. }