MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_recordToString

Function test_recordToString

tests/unit/test_record.c:20–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include "acutest.h"
19
20void 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
55TEST_LIST = {
56 { "recordToString", test_recordToString },

Callers

nothing calls this directly

Calls 10

Record_NewFunction · 0.85
SI_ConstStringValFunction · 0.85
SI_LongValFunction · 0.85
SI_DoubleValFunction · 0.85
SI_NullValFunction · 0.85
SI_BoolValFunction · 0.85
Record_AddScalarFunction · 0.85
Record_ToStringFunction · 0.85
rm_freeFunction · 0.85
Record_FreeFunction · 0.85

Tested by

no test coverage detected