tests/test_properties.c

changeset 929
192a440b99df
parent 928
d2d42cb1d59e
equal deleted inserted replaced
928:d2d42cb1d59e 929:192a440b99df
372 CX_TEST(test_cx_properties_load_string_to_map) { 372 CX_TEST(test_cx_properties_load_string_to_map) {
373 CxTestingAllocator talloc; 373 CxTestingAllocator talloc;
374 cx_testing_allocator_init(&talloc); 374 cx_testing_allocator_init(&talloc);
375 CxAllocator *alloc = &talloc.base; 375 CxAllocator *alloc = &talloc.base;
376 CX_TEST_DO { 376 CX_TEST_DO {
377 char buffer[512];
378 CxProperties prop;
379 cxPropertiesInitDefault(&prop);
380 cxPropertiesUseStack(&prop, buffer, 512);
381
377 const char *str = "key1 = value1\nkey2 = value2\n\n#comment\n\nkey3 = value3\n"; 382 const char *str = "key1 = value1\nkey2 = value2\n\n#comment\n\nkey3 = value3\n";
378 383
379 CxMap *map = cxHashMapCreateSimple(CX_STORE_POINTERS); 384 CxMap *map = cxHashMapCreateSimple(CX_STORE_POINTERS);
380 cxDefineAdvancedDestructor(map, cxFree, alloc); 385 cxDefineAdvancedDestructor(map, cxFree, alloc);
381 CxProperties prop;
382 cxPropertiesInitDefault(&prop);
383 CxPropertiesSink sink = cxPropertiesMapSink(map); 386 CxPropertiesSink sink = cxPropertiesMapSink(map);
384 sink.data = alloc; // use the testing allocator 387 sink.data = alloc; // use the testing allocator
385 CxPropertiesSource src = cxPropertiesCstrSource(str); 388 CxPropertiesSource src = cxPropertiesCstrSource(str);
386 CxPropertiesStatus status = cxPropertiesLoad(&prop, sink, src); 389 CxPropertiesStatus status = cxPropertiesLoad(&prop, sink, src);
387 390

mercurial