diff options
author | Jason Evans <jasone@canonware.com> | 2014-01-22 11:11:22 -0800 |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2014-01-22 11:11:22 -0800 |
commit | cc47dde16203a6ae7eb685b53e1ae501f3869bc6 (patch) | |
tree | 74e81d65651b2ca7e294a857797dda6635177454 /test/integration/xallocx.c | |
parent | 0135fb806e4137dc9cdf152541926a2bc95e33f0 (diff) | |
parent | 798a48103014aabf8afb3d7efff90399a466dd8c (diff) | |
download | jemalloc-3.5.0.tar.gz |
Merge branch 'dev'3.5.0
Diffstat (limited to 'test/integration/xallocx.c')
-rw-r--r-- | test/integration/xallocx.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/integration/xallocx.c b/test/integration/xallocx.c new file mode 100644 index 00000000..ab4cf945 --- /dev/null +++ b/test/integration/xallocx.c @@ -0,0 +1,59 @@ +#include "test/jemalloc_test.h" + +TEST_BEGIN(test_same_size) +{ + void *p; + size_t sz, tsz; + + p = mallocx(42, 0); + assert_ptr_not_null(p, "Unexpected mallocx() error"); + sz = sallocx(p, 0); + + tsz = xallocx(p, sz, 0, 0); + assert_zu_eq(tsz, sz, "Unexpected size change: %zu --> %zu", sz, tsz); + + dallocx(p, 0); +} +TEST_END + +TEST_BEGIN(test_extra_no_move) +{ + void *p; + size_t sz, tsz; + + p = mallocx(42, 0); + assert_ptr_not_null(p, "Unexpected mallocx() error"); + sz = sallocx(p, 0); + + tsz = xallocx(p, sz, sz-42, 0); + assert_zu_eq(tsz, sz, "Unexpected size change: %zu --> %zu", sz, tsz); + + dallocx(p, 0); +} +TEST_END + +TEST_BEGIN(test_no_move_fail) +{ + void *p; + size_t sz, tsz; + + p = mallocx(42, 0); + assert_ptr_not_null(p, "Unexpected mallocx() error"); + sz = sallocx(p, 0); + + tsz = xallocx(p, sz + 5, 0, 0); + assert_zu_eq(tsz, sz, "Unexpected size change: %zu --> %zu", sz, tsz); + + dallocx(p, 0); +} +TEST_END + +int +main(void) +{ + + return (test( + test_same_size, + test_extra_no_move, + test_no_move_fail)); +} |