| 18 | #include "acutest.h" |
| 19 | |
| 20 | void test_recordToString() { |
| 21 | rax *_rax = raxNew(); |
| 22 | |
| 23 | for(int i = 0; i < 6; i++) { |
| 24 | char buf[2] = {(char)i, '\0'}; |
| 25 | raxInsert(_rax, (unsigned char *)buf, 2, NULL, NULL); |
| 26 | } |
| 27 | |
| 28 | Record r = Record_New(_rax); |
| 29 | SIValue v_string = SI_ConstStringVal("Hello"); |
| 30 | SIValue v_int = SI_LongVal(-24); |
| 31 | SIValue v_uint = SI_LongVal(24); |
| 32 | SIValue v_double = SI_DoubleVal(0.314); |
| 33 | SIValue v_null = SI_NullVal(); |
| 34 | SIValue v_bool = SI_BoolVal(1); |
| 35 | |
| 36 | Record_AddScalar(r, 0, v_string); |
| 37 | Record_AddScalar(r, 1, v_int); |
| 38 | Record_AddScalar(r, 2, v_uint); |
| 39 | Record_AddScalar(r, 3, v_double); |
| 40 | Record_AddScalar(r, 4, v_null); |
| 41 | Record_AddScalar(r, 5, v_bool); |
| 42 | |
| 43 | size_t record_str_cap = 0; |
| 44 | char *record_str = NULL; |
| 45 | size_t record_str_len = Record_ToString(r, &record_str, &record_str_cap); |
| 46 | |
| 47 | TEST_ASSERT(record_str_len == 31); |
| 48 | TEST_ASSERT(strcmp(record_str, "Hello,-24,24,0.314000,NULL,true") == 0); |
| 49 | |
| 50 | rm_free(record_str); |
| 51 | Record_Free(r); |
| 52 | raxFree(_rax); |
| 53 | } |
| 54 | |
| 55 | TEST_LIST = { |
| 56 | { "recordToString", test_recordToString }, |
nothing calls this directly
no test coverage detected