tests/test_printf.c

changeset 890
54565fd74e74
parent 849
edb9f875b7f9
equal deleted inserted replaced
889:f549fd9fbd8f 890:54565fd74e74
34 34
35 #define ASSERT_ZERO_TERMINATED(str) CX_TEST_ASSERTM((str).ptr[(str).length] == '\0', \ 35 #define ASSERT_ZERO_TERMINATED(str) CX_TEST_ASSERTM((str).ptr[(str).length] == '\0', \
36 #str " is not zero terminated") 36 #str " is not zero terminated")
37 37
38 static size_t test_printf_write_func( 38 static size_t test_printf_write_func(
39 void const *src, 39 const void *src,
40 size_t esize, 40 size_t esize,
41 size_t ecount, 41 size_t ecount,
42 void *target 42 void *target
43 ) { 43 ) {
44 memcpy(target, src, esize * ecount); 44 memcpy(target, src, esize * ecount);
112 } 112 }
113 cx_testing_allocator_destroy(&talloc); 113 cx_testing_allocator_destroy(&talloc);
114 } 114 }
115 115
116 CX_TEST(test_fprintf) { 116 CX_TEST(test_fprintf) {
117 char const *h = "Hello"; 117 const char *h = "Hello";
118 char buf[32]; 118 char buf[32];
119 size_t r; 119 size_t r;
120 CX_TEST_DO { 120 CX_TEST_DO {
121 r = cx_fprintf(buf, test_printf_write_func, "teststring"); 121 r = cx_fprintf(buf, test_printf_write_func, "teststring");
122 CX_TEST_ASSERT(r == 10); 122 CX_TEST_ASSERT(r == 10);
175 CX_TEST(test_asprintf) { 175 CX_TEST(test_asprintf) {
176 CxTestingAllocator talloc; 176 CxTestingAllocator talloc;
177 cx_testing_allocator_init(&talloc); 177 cx_testing_allocator_init(&talloc);
178 CxAllocator *alloc = &talloc.base; 178 CxAllocator *alloc = &talloc.base;
179 179
180 char const *h = "Hello"; 180 const char *h = "Hello";
181 181
182 int const specimen_count = 13; 182 int const specimen_count = 13;
183 cxmutstr r[specimen_count]; 183 cxmutstr r[specimen_count];
184 int specimen = 0; 184 int specimen = 0;
185 185

mercurial