check_builtin.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. /*
  2. ============================================================================
  3. Name : check_stack.c
  4. Author :
  5. Version :
  6. Copyright : Your copyright notice
  7. Description :
  8. ============================================================================
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include "opcua.h"
  13. #include "check.h"
  14. START_TEST(UA_Boolean_calcSizeWithNullArgumentShallReturnStorageSize)
  15. {
  16. // given
  17. UA_Boolean* arg = UA_NULL;
  18. // when
  19. UA_Boolean storageSize = UA_Boolean_calcSize(arg);
  20. // then
  21. ck_assert_int_eq(storageSize, 1);
  22. }
  23. END_TEST
  24. START_TEST(UA_SByte_calcSizeWithNullArgumentShallReturnStorageSize)
  25. {
  26. // given
  27. UA_SByte* arg = UA_NULL;
  28. // when
  29. UA_Int32 storageSize = UA_SByte_calcSize(arg);
  30. // then
  31. ck_assert_int_ge(storageSize, 1);
  32. }
  33. END_TEST
  34. START_TEST(UA_Byte_calcSizeWithNullArgumentShallReturnStorageSize)
  35. {
  36. // given
  37. UA_Byte* arg = UA_NULL;
  38. // when
  39. UA_Int32 storageSize = UA_Byte_calcSize(arg);
  40. // then
  41. ck_assert_int_ge(storageSize, 1);
  42. }
  43. END_TEST
  44. START_TEST(UA_Int16_calcSizeWithNullArgumentShallReturnStorageSize)
  45. {
  46. // given
  47. UA_Int16* arg = UA_NULL;
  48. // when
  49. UA_Int32 storageSize = UA_Int16_calcSize(arg);
  50. // then
  51. ck_assert_int_ge(storageSize, 2);
  52. }
  53. END_TEST
  54. START_TEST(UA_UInt16_calcSizeWithNullArgumentShallReturnStorageSize)
  55. {
  56. // given
  57. UA_UInt16* arg = UA_NULL;
  58. // when
  59. UA_Int32 storageSize = UA_UInt16_calcSize(arg);
  60. // then
  61. ck_assert_int_ge(storageSize, 2);
  62. }
  63. END_TEST
  64. START_TEST(UA_Int32_calcSizeWithNullArgumentShallReturnStorageSize)
  65. {
  66. // given
  67. UA_Int32* arg = UA_NULL;
  68. // when
  69. UA_Int32 storageSize = UA_Int32_calcSize(arg);
  70. // then
  71. ck_assert_int_ge(storageSize, 4);
  72. }
  73. END_TEST
  74. START_TEST(UA_UInt32_calcSizeWithNullArgumentShallReturnStorageSize)
  75. {
  76. // given
  77. UA_UInt32* arg = UA_NULL;
  78. // when
  79. UA_Int32 storageSize = UA_UInt32_calcSize(arg);
  80. // then
  81. ck_assert_int_ge(storageSize, 4);
  82. }
  83. END_TEST
  84. START_TEST(UA_Int64_calcSizeWithNullArgumentShallReturnStorageSize)
  85. {
  86. // given
  87. UA_Int64* arg = UA_NULL;
  88. // when
  89. UA_Int32 storageSize = UA_Int64_calcSize(arg);
  90. // then
  91. ck_assert_int_ge(storageSize, 8);
  92. }
  93. END_TEST
  94. START_TEST(UA_UInt64_calcSizeWithNullArgumentShallReturnStorageSize)
  95. {
  96. // given
  97. UA_UInt64* arg = UA_NULL;
  98. // when
  99. UA_Int32 storageSize = UA_UInt64_calcSize(arg);
  100. // then
  101. ck_assert_int_ge(storageSize, 8);
  102. }
  103. END_TEST
  104. START_TEST(UA_Float_calcSizeWithNullArgumentShallReturnStorageSize)
  105. {
  106. // given
  107. UA_Float* arg = UA_NULL;
  108. // when
  109. UA_Int32 storageSize = UA_Float_calcSize(arg);
  110. // then
  111. ck_assert_int_ge(storageSize, 4);
  112. }
  113. END_TEST
  114. START_TEST(UA_Double_calcSizeWithNullArgumentShallReturnStorageSize)
  115. {
  116. // given
  117. UA_Double* arg = UA_NULL;
  118. // when
  119. UA_Int32 storageSize = UA_Double_calcSize(arg);
  120. // then
  121. ck_assert_int_ge(storageSize, 8);
  122. }
  123. END_TEST
  124. START_TEST(UA_String_calcSizeWithNullArgumentShallReturnStorageSize)
  125. {
  126. // given
  127. UA_String* arg = UA_NULL;
  128. // when
  129. UA_Int32 storageSize = UA_String_calcSize(arg);
  130. // then
  131. ck_assert_int_eq(storageSize, sizeof(UA_String));
  132. ck_assert_int_ge(storageSize, UA_Int32_calcSize(UA_NULL) + sizeof(UA_NULL));
  133. }
  134. END_TEST
  135. START_TEST(UA_DateTime_calcSizeWithNullArgumentShallReturnStorageSize)
  136. {
  137. // given
  138. UA_DateTime* arg = UA_NULL;
  139. // when
  140. UA_Int32 storageSize = UA_DateTime_calcSize(arg);
  141. // then
  142. ck_assert_int_ge(storageSize, 8);
  143. }
  144. END_TEST
  145. START_TEST(UA_Guid_calcSizeWithNullArgumentShallReturnStorageSize)
  146. {
  147. // given
  148. UA_Guid* arg = UA_NULL;
  149. // when
  150. UA_Int32 storageSize = UA_Guid_calcSize(arg);
  151. // then
  152. ck_assert_int_ge(storageSize, 16);
  153. }
  154. END_TEST
  155. START_TEST(UA_ByteString_calcSizeWithNullArgumentShallReturnStorageSize)
  156. {
  157. // given
  158. UA_ByteString* arg = UA_NULL;
  159. // when
  160. UA_Int32 storageSize = UA_ByteString_calcSize(arg);
  161. // then
  162. ck_assert_int_eq(storageSize, sizeof(UA_ByteString));
  163. ck_assert_int_ge(storageSize, UA_Int32_calcSize(UA_NULL)+sizeof(UA_NULL));
  164. }
  165. END_TEST
  166. START_TEST(UA_XmlElement_calcSizeWithNullArgumentShallReturnStorageSize)
  167. {
  168. // given
  169. UA_XmlElement* arg = UA_NULL;
  170. // when
  171. UA_Int32 storageSize = UA_XmlElement_calcSize(arg);
  172. // then
  173. ck_assert_int_eq(storageSize, sizeof(UA_XmlElement));
  174. ck_assert_int_ge(storageSize, UA_Int32_calcSize(UA_NULL)+sizeof(UA_NULL));
  175. }
  176. END_TEST
  177. START_TEST(UA_NodeId_calcSizeWithNullArgumentShallReturnStorageSize)
  178. {
  179. // given
  180. UA_NodeId* arg = UA_NULL;
  181. // when
  182. UA_Int32 storageSize = UA_NodeId_calcSize(arg);
  183. // then
  184. ck_assert_int_eq(storageSize, sizeof(UA_NodeId));
  185. }
  186. END_TEST
  187. START_TEST(UA_ExpandedNodeId_calcSizeWithNullArgumentShallReturnStorageSize)
  188. {
  189. // given
  190. UA_ExpandedNodeId* arg = UA_NULL;
  191. // when
  192. UA_Int32 storageSize = UA_ExpandedNodeId_calcSize(arg);
  193. // then
  194. ck_assert_int_eq(storageSize, sizeof(UA_ExpandedNodeId));
  195. }
  196. END_TEST
  197. START_TEST(UA_StatusCode_calcSizeWithNullArgumentShallReturnStorageSize)
  198. {
  199. // given
  200. UA_StatusCode* arg = UA_NULL;
  201. // when
  202. UA_Int32 storageSize = UA_StatusCode_calcSize(arg);
  203. // then
  204. ck_assert_int_eq(storageSize, sizeof(UA_StatusCode));
  205. }
  206. END_TEST
  207. START_TEST(UA_QualifiedName_calcSizeWithNullArgumentShallReturnStorageSize)
  208. {
  209. // given
  210. UA_QualifiedName* arg = UA_NULL;
  211. // when
  212. UA_Int32 storageSize = UA_QualifiedName_calcSize(arg);
  213. // then
  214. ck_assert_int_eq(storageSize, sizeof(UA_QualifiedName));
  215. }
  216. END_TEST
  217. START_TEST(UA_LocalizedText_calcSizeWithNullArgumentShallReturnStorageSize)
  218. {
  219. // given
  220. UA_LocalizedText* arg = UA_NULL;
  221. // when
  222. UA_Int32 storageSize = UA_LocalizedText_calcSize(arg);
  223. // then
  224. ck_assert_int_eq(storageSize, sizeof(UA_LocalizedText));
  225. }
  226. END_TEST
  227. START_TEST(UA_ExtensionObject_calcSizeWithNullArgumentShallReturnStorageSize)
  228. {
  229. // given
  230. UA_ExtensionObject* arg = UA_NULL;
  231. // when
  232. UA_Int32 storageSize = UA_ExtensionObject_calcSize(arg);
  233. // then
  234. ck_assert_int_eq(storageSize, sizeof(UA_ExtensionObject));
  235. }
  236. END_TEST
  237. START_TEST(UA_DataValue_calcSizeWithNullArgumentShallReturnStorageSize)
  238. {
  239. // given
  240. UA_DataValue* arg = UA_NULL;
  241. // when
  242. UA_Int32 storageSize = UA_DataValue_calcSize(arg);
  243. // then
  244. ck_assert_int_eq(storageSize, sizeof(UA_DataValue));
  245. }
  246. END_TEST
  247. START_TEST(UA_Variant_calcSizeWithNullArgumentShallReturnStorageSize)
  248. {
  249. // given
  250. UA_Variant* arg = UA_NULL;
  251. // when
  252. UA_Int32 storageSize = UA_Variant_calcSize(arg);
  253. // then
  254. ck_assert_int_eq(storageSize, sizeof(UA_Variant));
  255. }
  256. END_TEST
  257. START_TEST(UA_DiagnosticInfo_calcSizeWithNullArgumentShallReturnStorageSize)
  258. {
  259. // given
  260. UA_DiagnosticInfo* arg = UA_NULL;
  261. // when
  262. UA_Int32 storageSize = UA_DiagnosticInfo_calcSize(arg);
  263. // then
  264. ck_assert_int_eq(storageSize, sizeof(UA_DiagnosticInfo));
  265. }
  266. END_TEST
  267. START_TEST(UA_String_calcSizeWithNegativLengthShallReturnEncodingSize)
  268. {
  269. // given
  270. UA_String arg = {-1, UA_NULL};
  271. // when
  272. UA_Int32 encodingSize = UA_String_calcSize(&arg);
  273. // then
  274. ck_assert_int_eq(encodingSize, 4);
  275. }
  276. END_TEST
  277. START_TEST(UA_String_calcSizeWithNegativLengthAndValidPointerShallReturnEncodingSize)
  278. {
  279. // given
  280. UA_String arg = {-1, "OPC"};
  281. // when
  282. UA_Int32 encodingSize = UA_String_calcSize(&arg);
  283. // then
  284. ck_assert_int_eq(encodingSize, 4);
  285. }
  286. END_TEST
  287. START_TEST(UA_String_calcSizeWithZeroLengthShallReturnEncodingSize)
  288. {
  289. // given
  290. UA_String arg = {0, UA_NULL};
  291. // when
  292. UA_Int32 encodingSize = UA_String_calcSize(&arg);
  293. // then
  294. ck_assert_int_eq(encodingSize, 4);
  295. }
  296. END_TEST
  297. START_TEST(UA_String_calcSizeWithZeroLengthAndValidPointerShallReturnEncodingSize)
  298. {
  299. // given
  300. UA_String arg = {0, "OPC"};
  301. // when
  302. UA_Int32 encodingSize = UA_String_calcSize(&arg);
  303. // then
  304. ck_assert_int_eq(encodingSize, 4);
  305. }
  306. END_TEST
  307. START_TEST(UA_String_calcSizeShallReturnEncodingSize)
  308. {
  309. // given
  310. UA_String arg = {3, "OPC"};
  311. // when
  312. UA_Int32 encodingSize = UA_String_calcSize(&arg);
  313. // then
  314. ck_assert_int_eq(encodingSize, 4+3);
  315. }
  316. END_TEST
  317. START_TEST(UA_NodeId_calcSizeEncodingTwoByteShallReturnEncodingSize)
  318. {
  319. // given
  320. UA_NodeId arg;
  321. arg.encodingByte = UA_NODEIDTYPE_TWOBYTE;
  322. // when
  323. UA_Int32 encodingSize = UA_NodeId_calcSize(&arg);
  324. // then
  325. ck_assert_int_eq(encodingSize, 2);
  326. }
  327. END_TEST
  328. START_TEST(UA_NodeId_calcSizeEncodingFourByteShallReturnEncodingSize)
  329. {
  330. // given
  331. UA_NodeId arg;
  332. arg.encodingByte = UA_NODEIDTYPE_FOURBYTE;
  333. // when
  334. UA_Int32 encodingSize = UA_NodeId_calcSize(&arg);
  335. // then
  336. ck_assert_int_eq(encodingSize, 4);
  337. }
  338. END_TEST
  339. START_TEST(UA_NodeId_calcSizeEncodingStringShallReturnEncodingSize)
  340. {
  341. // given
  342. UA_NodeId arg;
  343. arg.encodingByte = UA_NODEIDTYPE_STRING;
  344. arg.identifier.string.length = 3;
  345. arg.identifier.string.data = "PLT";
  346. // when
  347. UA_Int32 encodingSize = UA_NodeId_calcSize(&arg);
  348. // then
  349. ck_assert_int_eq(encodingSize, 1+2+4+3);
  350. }
  351. END_TEST
  352. START_TEST(UA_NodeId_calcSizeEncodingStringNegativLengthShallReturnEncodingSize)
  353. {
  354. // given
  355. UA_NodeId arg;
  356. arg.encodingByte = UA_NODEIDTYPE_STRING;
  357. arg.identifier.string.length = -1;
  358. // when
  359. UA_Int32 encodingSize = UA_NodeId_calcSize(&arg);
  360. // then
  361. ck_assert_int_eq(encodingSize, 1+2+4+0);
  362. }
  363. END_TEST
  364. START_TEST(UA_NodeId_calcSizeEncodingStringZeroLengthShallReturnEncodingSize)
  365. {
  366. // given
  367. UA_NodeId arg;
  368. arg.encodingByte = UA_NODEIDTYPE_STRING;
  369. arg.identifier.string.length = 0;
  370. // when
  371. UA_Int32 encodingSize = UA_NodeId_calcSize(&arg);
  372. // then
  373. ck_assert_int_eq(encodingSize, 1+2+4+0);
  374. }
  375. END_TEST
  376. START_TEST(UA_ExpandedNodeId_calcSizeEncodingStringAndServerIndexShallReturnEncodingSize)
  377. {
  378. // given
  379. UA_ExpandedNodeId arg;
  380. arg.nodeId.encodingByte = UA_NODEIDTYPE_STRING | UA_NODEIDTYPE_SERVERINDEX_FLAG;
  381. arg.nodeId.identifier.string.length = 3;
  382. // when
  383. UA_Int32 encodingSize = UA_ExpandedNodeId_calcSize(&arg);
  384. // then
  385. ck_assert_int_eq(encodingSize, 1+2+4+3+4);
  386. }
  387. END_TEST
  388. START_TEST(UA_ExpandedNodeId_calcSizeEncodingStringAndNamespaceUriShallReturnEncodingSize)
  389. {
  390. // given
  391. UA_ExpandedNodeId arg;
  392. arg.nodeId.encodingByte = UA_NODEIDTYPE_STRING | UA_NODEIDTYPE_NAMESPACE_URI_FLAG;
  393. arg.nodeId.identifier.string.length = 3;
  394. arg.namespaceUri.length = 7;
  395. // when
  396. UA_Int32 encodingSize = UA_ExpandedNodeId_calcSize(&arg);
  397. // then
  398. ck_assert_int_eq(encodingSize, 1+2+4+3+4+7);
  399. }
  400. END_TEST
  401. START_TEST(UA_Byte_decode_test)
  402. {
  403. UA_Byte dst;
  404. UA_Byte src[] = { 0x08 };
  405. UA_Int32 retval, pos = 0;
  406. retval = UA_Byte_decode(src, &pos, &dst);
  407. ck_assert_int_eq(retval, UA_SUCCESS);
  408. ck_assert_uint_eq(pos, 1);
  409. ck_assert_uint_eq(dst, 8);
  410. }
  411. END_TEST
  412. START_TEST(UA_Byte_encode_test)
  413. {
  414. UA_Byte src;
  415. UA_Byte dst[2] = { 0x00, 0xFF };
  416. UA_Int32 retval, pos = 0;
  417. ck_assert_uint_eq(dst[1], 0xFF);
  418. src = 8;
  419. retval = UA_Byte_encode(&src, &pos, dst);
  420. ck_assert_uint_eq(dst[0], 0x08);
  421. ck_assert_uint_eq(dst[1], 0xFF);
  422. ck_assert_int_eq(pos, 1);
  423. ck_assert_int_eq(retval, UA_SUCCESS);
  424. src = 0xFF;
  425. dst[1] = 0x00;
  426. pos = 0;
  427. retval = UA_Byte_encode(&src, &pos, dst);
  428. ck_assert_int_eq(dst[0], 0xFF);
  429. ck_assert_int_eq(dst[1], 0x00);
  430. ck_assert_int_eq(pos, 1);
  431. ck_assert_int_eq(retval, UA_SUCCESS);
  432. }
  433. END_TEST
  434. START_TEST(UA_Int16_decode_test_positives)
  435. {
  436. UA_Int32 p = 0;
  437. UA_Int16 val;
  438. UA_Int32 retval;
  439. UA_Byte buf[] = {
  440. 0x00,0x00, // 0
  441. 0x01,0x00, // 1
  442. 0xFF,0x00, // 255
  443. 0x00,0x01, // 256
  444. };
  445. retval = UA_Int16_decode(buf,&p,&val);
  446. ck_assert_int_eq(retval,UA_SUCCESS);
  447. ck_assert_int_eq(val,0);
  448. retval = UA_Int16_decode(buf,&p,&val);
  449. ck_assert_int_eq(retval,UA_SUCCESS);
  450. ck_assert_int_eq(val,1);
  451. retval = UA_Int16_decode(buf,&p,&val);
  452. ck_assert_int_eq(retval,UA_SUCCESS);
  453. ck_assert_int_eq(val,255);
  454. retval = UA_Int16_decode(buf,&p,&val);
  455. ck_assert_int_eq(retval,UA_SUCCESS);
  456. ck_assert_int_eq(val,256);
  457. }
  458. END_TEST
  459. START_TEST(UA_Int16_decode_test_negatives)
  460. {
  461. UA_Int32 p = 0;
  462. UA_Int16 val;
  463. UA_Int32 retval;
  464. UA_Byte mem[] = {
  465. 0xFF,0xFF, // -1
  466. 0x00,0x80, // -32768
  467. };
  468. retval = UA_Int16_decode(mem,&p,&val);
  469. ck_assert_int_eq(retval,UA_SUCCESS);
  470. ck_assert_int_eq(val,-1);
  471. retval = UA_Int16_decode(mem,&p,&val);
  472. ck_assert_int_eq(retval,UA_SUCCESS);
  473. ck_assert_int_eq(val,-32768);
  474. }
  475. END_TEST
  476. Suite *testSuite_builtin(void)
  477. {
  478. Suite *s = suite_create("Built-in Data Types 62541-6 Table 1");
  479. TCase *tc_calcSize = tcase_create("calcSize");
  480. tcase_add_test(tc_calcSize, UA_Boolean_calcSizeWithNullArgumentShallReturnStorageSize);
  481. tcase_add_test(tc_calcSize, UA_SByte_calcSizeWithNullArgumentShallReturnStorageSize);
  482. tcase_add_test(tc_calcSize, UA_Byte_calcSizeWithNullArgumentShallReturnStorageSize);
  483. tcase_add_test(tc_calcSize, UA_Int16_calcSizeWithNullArgumentShallReturnStorageSize);
  484. tcase_add_test(tc_calcSize, UA_UInt16_calcSizeWithNullArgumentShallReturnStorageSize);
  485. tcase_add_test(tc_calcSize, UA_Int32_calcSizeWithNullArgumentShallReturnStorageSize);
  486. tcase_add_test(tc_calcSize, UA_UInt32_calcSizeWithNullArgumentShallReturnStorageSize);
  487. tcase_add_test(tc_calcSize, UA_Int64_calcSizeWithNullArgumentShallReturnStorageSize);
  488. tcase_add_test(tc_calcSize, UA_UInt64_calcSizeWithNullArgumentShallReturnStorageSize);
  489. tcase_add_test(tc_calcSize, UA_Float_calcSizeWithNullArgumentShallReturnStorageSize);
  490. tcase_add_test(tc_calcSize, UA_Double_calcSizeWithNullArgumentShallReturnStorageSize);
  491. tcase_add_test(tc_calcSize, UA_String_calcSizeWithNullArgumentShallReturnStorageSize);
  492. tcase_add_test(tc_calcSize, UA_DateTime_calcSizeWithNullArgumentShallReturnStorageSize);
  493. tcase_add_test(tc_calcSize, UA_Guid_calcSizeWithNullArgumentShallReturnStorageSize);
  494. tcase_add_test(tc_calcSize, UA_ByteString_calcSizeWithNullArgumentShallReturnStorageSize);
  495. tcase_add_test(tc_calcSize, UA_XmlElement_calcSizeWithNullArgumentShallReturnStorageSize);
  496. tcase_add_test(tc_calcSize, UA_NodeId_calcSizeWithNullArgumentShallReturnStorageSize);
  497. tcase_add_test(tc_calcSize, UA_ExpandedNodeId_calcSizeWithNullArgumentShallReturnStorageSize);
  498. tcase_add_test(tc_calcSize, UA_StatusCode_calcSizeWithNullArgumentShallReturnStorageSize);
  499. tcase_add_test(tc_calcSize, UA_QualifiedName_calcSizeWithNullArgumentShallReturnStorageSize);
  500. tcase_add_test(tc_calcSize, UA_LocalizedText_calcSizeWithNullArgumentShallReturnStorageSize);
  501. tcase_add_test(tc_calcSize, UA_ExtensionObject_calcSizeWithNullArgumentShallReturnStorageSize);
  502. tcase_add_test(tc_calcSize, UA_DataValue_calcSizeWithNullArgumentShallReturnStorageSize);
  503. tcase_add_test(tc_calcSize, UA_Variant_calcSizeWithNullArgumentShallReturnStorageSize);
  504. tcase_add_test(tc_calcSize, UA_DiagnosticInfo_calcSizeWithNullArgumentShallReturnStorageSize);
  505. tcase_add_test(tc_calcSize, UA_String_calcSizeShallReturnEncodingSize);
  506. tcase_add_test(tc_calcSize, UA_String_calcSizeWithNegativLengthShallReturnEncodingSize);
  507. tcase_add_test(tc_calcSize, UA_String_calcSizeWithNegativLengthAndValidPointerShallReturnEncodingSize);
  508. tcase_add_test(tc_calcSize, UA_String_calcSizeWithZeroLengthShallReturnEncodingSize);
  509. tcase_add_test(tc_calcSize, UA_String_calcSizeWithZeroLengthAndValidPointerShallReturnEncodingSize);
  510. tcase_add_test(tc_calcSize, UA_NodeId_calcSizeEncodingTwoByteShallReturnEncodingSize);
  511. tcase_add_test(tc_calcSize, UA_NodeId_calcSizeEncodingFourByteShallReturnEncodingSize);
  512. tcase_add_test(tc_calcSize, UA_NodeId_calcSizeEncodingStringShallReturnEncodingSize);
  513. tcase_add_test(tc_calcSize, UA_NodeId_calcSizeEncodingStringNegativLengthShallReturnEncodingSize);
  514. tcase_add_test(tc_calcSize, UA_NodeId_calcSizeEncodingStringZeroLengthShallReturnEncodingSize);
  515. tcase_add_test(tc_calcSize, UA_ExpandedNodeId_calcSizeEncodingStringAndServerIndexShallReturnEncodingSize);
  516. tcase_add_test(tc_calcSize, UA_ExpandedNodeId_calcSizeEncodingStringAndNamespaceUriShallReturnEncodingSize);
  517. suite_add_tcase(s,tc_calcSize);
  518. TCase *tc_decode = tcase_create("decode");
  519. tcase_add_test(tc_decode, UA_Byte_decode_test);
  520. tcase_add_test(tc_decode, UA_Byte_encode_test);
  521. tcase_add_test(tc_decode, UA_Int16_decode_test_negatives);
  522. tcase_add_test(tc_decode, UA_Int16_decode_test_positives);
  523. tcase_add_test(tc_decode, UA_Byte_encode_test);
  524. suite_add_tcase(s,tc_decode);
  525. return s;
  526. }
  527. int main (void)
  528. {
  529. int number_failed = 0;
  530. Suite* s;
  531. SRunner* sr;
  532. s = testSuite_builtin();
  533. sr = srunner_create(s);
  534. srunner_run_all(sr,CK_NORMAL);
  535. number_failed += srunner_ntests_failed(sr);
  536. srunner_free(sr);
  537. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  538. }