check_services_view.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include "check.h"
  7. #include "ua_server.h"
  8. #include "ua_config_standard.h"
  9. START_TEST(Service_Browse_WithBrowseName)
  10. {
  11. UA_Server * server = UA_Server_new(UA_ServerConfig_standard);
  12. UA_BrowseDescription bd;
  13. UA_BrowseDescription_init(&bd);
  14. bd.resultMask = UA_BROWSERESULTMASK_BROWSENAME;
  15. bd.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  16. bd.referenceTypeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  17. bd.browseDirection = UA_BROWSEDIRECTION_FORWARD;
  18. UA_BrowseResult br = UA_Server_browse(server, 0, &bd);
  19. ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
  20. ck_assert(br.referencesSize > 0);
  21. ck_assert(!UA_String_equal(&br.references[0].browseName.name, &UA_STRING_NULL));
  22. UA_BrowseResult_deleteMembers(&br);
  23. UA_Server_delete(server);
  24. }
  25. END_TEST
  26. static Suite* testSuite_Service_TranslateBrowsePathsToNodeIds(void) {
  27. Suite *s = suite_create("Service_TranslateBrowsePathsToNodeIds");
  28. TCase *tc_browse = tcase_create("Browse Service");
  29. tcase_add_test(tc_browse, Service_Browse_WithBrowseName);
  30. suite_add_tcase(s,tc_browse);
  31. return s;
  32. }
  33. int main(void) {
  34. int number_failed = 0;
  35. Suite *s;
  36. SRunner *sr;
  37. s = testSuite_Service_TranslateBrowsePathsToNodeIds();
  38. sr = srunner_create(s);
  39. srunner_set_fork_status(sr, CK_NOFORK);
  40. srunner_run_all(sr, CK_NORMAL);
  41. number_failed += srunner_ntests_failed(sr);
  42. srunner_free(sr);
  43. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  44. }