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

Function test_map_tostring

tests/unit/test_map.c:149–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149void test_map_tostring() {
150 SIValue k;
151 SIValue v;
152 SIValue map = Map_New(3);
153 SIValue inner_map = Map_New(3);
154
155 k = SI_ConstStringVal("inner_key");
156 v = SI_NullVal();
157 Map_Add(&inner_map, k, v);
158
159 k = SI_ConstStringVal("key0");
160 v = SI_LongVal(0);
161 Map_Add(&map, k, v);
162
163 k = SI_ConstStringVal("key1");
164 v = SI_DoubleVal(1);
165 Map_Add(&map, k, v);
166
167 k = SI_ConstStringVal("key2");
168 v = SI_ConstStringVal("val0");
169 Map_Add(&map, k, v);
170
171 k = SI_ConstStringVal("key3");
172 Map_Add(&map, k, inner_map);
173
174 size_t buf_len = 256;
175 size_t bytes_written = 0;
176 char *buf = (char *)rm_malloc(sizeof(char) * 256);
177 Map_ToString(map, &buf, &buf_len, &bytes_written);
178
179 TEST_ASSERT(strcmp(buf, "{key0: 0, key1: 1.000000, key2: val0, key3: {inner_key: NULL}}") == 0);
180
181 rm_free(buf);
182 SIValue_Free(map);
183 SIValue_Free(inner_map);
184}
185
186TEST_LIST = {
187 {"empty_map", test_empty_map},

Callers

nothing calls this directly

Calls 10

Map_NewFunction · 0.85
SI_ConstStringValFunction · 0.85
SI_NullValFunction · 0.85
Map_AddFunction · 0.85
SI_LongValFunction · 0.85
SI_DoubleValFunction · 0.85
rm_mallocFunction · 0.85
Map_ToStringFunction · 0.85
rm_freeFunction · 0.85
SIValue_FreeFunction · 0.85

Tested by

no test coverage detected