test/utils_tests.c

changeset 147
1aa598f36872
parent 145
e974640ec4e0
child 168
24a012440dee
equal deleted inserted replaced
146:aa376dba1ba8 147:1aa598f36872
44 UCX_TEST_ASSERT(!strcmp(b1->space, "Hello World"), "wrong content in b1"); 44 UCX_TEST_ASSERT(!strcmp(b1->space, "Hello World"), "wrong content in b1");
45 ucx_fprintf(b1, (write_func)ucx_buffer_write, "\nend.\n"); 45 ucx_fprintf(b1, (write_func)ucx_buffer_write, "\nend.\n");
46 UCX_TEST_ASSERT(!strcmp(b1->space, "Hello World\nend.\n"), 46 UCX_TEST_ASSERT(!strcmp(b1->space, "Hello World\nend.\n"),
47 "wrong content in b1 after second fprintf"); 47 "wrong content in b1 after second fprintf");
48 48
49 ucx_fprintf(b2, (write_func)ucx_buffer_write, "%s%s", teststr1, teststr2); 49 ucx_bprintf(b2, "%s%s", teststr1, teststr2);
50 UCX_TEST_ASSERT(b2->pos == 2046, "wrong length"); 50 UCX_TEST_ASSERT(b2->pos == 2046, "wrong length");
51 UCX_TEST_ASSERT(!memcmp(b2->space, teststr1, 1023), 51 UCX_TEST_ASSERT(!memcmp(b2->space, teststr1, 1023),
52 "wrong first half in b2"); 52 "wrong first half in b2");
53 UCX_TEST_ASSERT(!memcmp(b2->space+1023, teststr2, 1023), 53 UCX_TEST_ASSERT(!memcmp(b2->space+1023, teststr2, 1023),
54 "wrong second half in b2"); 54 "wrong second half in b2");
55 55
56 UCX_TEST_END 56 UCX_TEST_END
57 57
58 ucx_buffer_free(b1); 58 ucx_buffer_free(b1);
59 ucx_buffer_free(b2); 59 ucx_buffer_free(b2);
60 free(teststr1);
61 free(teststr2);
60 } 62 }
61 63
62 UCX_TEST(test_ucx_asprintf) { 64 UCX_TEST(test_ucx_asprintf) {
63 char *teststr1 = (char*)calloc(1, 1024); 65 char *teststr1 = (char*)calloc(1, 1024);
64 char *teststr2 = (char*)calloc(1, 1024); 66 char *teststr2 = (char*)calloc(1, 1024);
82 UCX_TEST_ASSERT(!memcmp(s2.ptr+1023, teststr2, 1023), 84 UCX_TEST_ASSERT(!memcmp(s2.ptr+1023, teststr2, 1023),
83 "wrong second half in s2"); 85 "wrong second half in s2");
84 free(s2.ptr); 86 free(s2.ptr);
85 87
86 UCX_TEST_END 88 UCX_TEST_END
89
90 free(teststr1);
91 free(teststr2);
87 } 92 }

mercurial