check_services_view.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "check.h"
  4. #include "ua_server.h"
  5. #include "ua_config_standard.h"
  6. START_TEST(Service_Browse_WithBrowseName)
  7. {
  8. UA_Server * server = UA_Server_new(UA_ServerConfig_standard);
  9. UA_BrowseDescription bd;
  10. UA_BrowseDescription_init(&bd);
  11. bd.resultMask = UA_BROWSERESULTMASK_BROWSENAME;
  12. bd.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  13. bd.referenceTypeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  14. bd.browseDirection = UA_BROWSEDIRECTION_FORWARD;
  15. UA_BrowseResult br = UA_Server_browse(server, 0, &bd);
  16. ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
  17. ck_assert(br.referencesSize > 0);
  18. ck_assert(!UA_String_equal(&br.references[0].browseName.name, &UA_STRING_NULL));
  19. UA_BrowseResult_deleteMembers(&br);
  20. UA_Server_delete(server);
  21. }
  22. END_TEST
  23. static Suite* testSuite_Service_TranslateBrowsePathsToNodeIds(void) {
  24. Suite *s = suite_create("Service_TranslateBrowsePathsToNodeIds");
  25. TCase *tc_browse = tcase_create("Browse Service");
  26. tcase_add_test(tc_browse, Service_Browse_WithBrowseName);
  27. suite_add_tcase(s,tc_browse);
  28. return s;
  29. }
  30. int main(void) {
  31. int number_failed = 0;
  32. Suite *s;
  33. SRunner *sr;
  34. s = testSuite_Service_TranslateBrowsePathsToNodeIds();
  35. sr = srunner_create(s);
  36. srunner_set_fork_status(sr, CK_NOFORK);
  37. srunner_run_all(sr, CK_NORMAL);
  38. number_failed += srunner_ntests_failed(sr);
  39. srunner_free(sr);
  40. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  41. }