Advertisement
Guest User

Untitled

a guest
May 21st, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. //NEW
  2. UNIT_TEST(add_msg_and_read_label){
  3. UNIT_TEST_BEGIN();
  4.  
  5. init_json_decoder("[{\"bn\": \"urn:mac:testID\"}]");
  6. add_new_msg("[{\"u\": \"dB\"}]");
  7. struct pair lv;
  8. read_next_token(&lv);
  9. read_next_token(&lv);
  10.  
  11. UNIT_TEST_ASSERT(strcmp(lv.label, "u") == 0);
  12. UNIT_TEST_END();
  13. }
  14.  
  15. UNIT_TEST(add_msg_and_read_value_str){
  16. UNIT_TEST_BEGIN();
  17.  
  18. init_json_decoder("[{\"bn\": \"urn:mac:testID\"}]");
  19. add_new_msg("[{\"u\": \"dB\"}]");
  20. struct pair lv;
  21. read_next_token(&lv);
  22. read_next_token(&lv);
  23.  
  24. UNIT_TEST_ASSERT(strcmp(lv.label, "dB") == 0);
  25. UNIT_TEST_END();
  26. }
  27.  
  28. UNIT_TEST(add_msg_and_read_value_int){
  29. UNIT_TEST_BEGIN();
  30.  
  31. init_json_decoder("[{\"bn\": \"urn:mac:testID\"}]");
  32. add_new_msg("[{\"v\": 10}]");
  33. struct pair lv;
  34. read_next_token(&lv);
  35. read_next_token(&lv);
  36.  
  37. UNIT_TEST_ASSERT(lv.value == 10);
  38. UNIT_TEST_END();
  39. }
  40.  
  41. UNIT_TEST(read_add_read_label){
  42. UNIT_TEST_BEGIN();
  43.  
  44. init_json_decoder("[{\"bn\": \"urn:mac:testID\"}]");
  45. struct pair lv;
  46. read_next_token(&lv);
  47. add_new_msg("[{\"v\": 10}]");
  48. read_next_token(&lv);
  49.  
  50. UNIT_TEST_ASSERT(strcmp(lv.label, "v") == 0);
  51. UNIT_TEST_END();
  52. }
  53.  
  54. UNIT_TEST(read_add_read_value_str){
  55. UNIT_TEST_BEGIN();
  56.  
  57. init_json_decoder("[{\"bn\": \"urn:mac:testID\"}]");
  58. struct pair lv;
  59. read_next_token(&lv);
  60. add_new_msg("[{\"u\": \"dB\"}]");
  61. read_next_token(&lv);
  62.  
  63. UNIT_TEST_ASSERT(strcmp(lv.label, "dB") == 0);
  64. UNIT_TEST_END();
  65. }
  66.  
  67. UNIT_TEST(read_add_read_value_int){
  68. UNIT_TEST_BEGIN();
  69.  
  70. init_json_decoder("[{\"bn\": \"urn:mac:testID\"}]");
  71. struct pair lv;
  72. read_next_token(&lv);
  73. add_new_msg("[{\"v\": 10}]");
  74. read_next_token(&lv);
  75.  
  76. UNIT_TEST_ASSERT(lv.value == 10);
  77. UNIT_TEST_END();
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement