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); |