check_server-api.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "open62541.h"
  2. #include "open62541-server.h"
  3. #include "check.h"
  4. START_TEST(addingVariableNodeTwiceShallRedirectPointer) {
  5. //GIVEN
  6. UA_Int32 myInteger = 0, otherInteger = 0;
  7. UA_NodeId myIntegerNode = {1, UA_NODEIDTYPE_NUMERIC, 50};
  8. //WHEN
  9. UA_Application_addVariableNode(application, &myIntegerNode, UA_INT32, &myInteger);
  10. UA_Application_addVariableNode(application, &myIntegerNode, UA_INT32, &otherInteger);
  11. //THEN
  12. ck_assert_ptr_eq(otherInteger,UA_Application_getVariableNodeAppPtr(application, &myIntegerNode);
  13. }
  14. END_TEST
  15. START_TEST(addingDifferentVariableNodesWithSameMemoryShallResultInTwoViewsOnOneMemoryLocation) {
  16. //GIVEN
  17. UA_Int32 myInteger = 0;
  18. UA_NodeId myIntegerNode = {1, UA_NODEIDTYPE_NUMERIC, 50};
  19. UA_NodeId otherIntegerNode = {1, UA_NODEIDTYPE_NUMERIC, 51};
  20. //WHEN
  21. UA_Application_addVariableNode(application, &myIntegerNode, UA_INT32, &myInteger);
  22. UA_Application_addVariableNode(application, &otherIntegerNode, UA_INT32, &myInteger);
  23. //THEN
  24. ck_assert_ptr_eq(myInteger,UA_Application_getVariableNodeAppPtr(application, &myIntegerNode);
  25. ck_assert_ptr_eq(myInteger,UA_Application_getVariableNodeAppPtr(application, &otherIntegerNode);
  26. }
  27. END_TEST
  28. Suite *testSuite_builtin(void) {
  29. Suite *s = suite_create("Test api");
  30. TCase *tc_ns0 = tcase_create("populating namespaces");
  31. tcase_add_test(tc_ns0, addingVariableNodeTwiceShallRedirectPointer);
  32. tcase_add_test(tc_ns0, addingDifferentVariableNodesWithSameMemoryShallResultInTwoViewsOnOneMemoryLocation);
  33. suite_add_tcase(s, tc_ns0);
  34. return s;
  35. }
  36. int main(void) {
  37. int number_failed = 0;
  38. Suite *s;
  39. SRunner *sr;
  40. s = testSuite_builtin();
  41. sr = srunner_create(s);
  42. //srunner_set_fork_status(sr, CK_NOFORK);
  43. srunner_run_all(sr, CK_NORMAL);
  44. number_failed += srunner_ntests_failed(sr);
  45. srunner_free(sr);
  46. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  47. }