summaryrefslogtreecommitdiffstats
path: root/test/test_string_view.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-09-28 11:14:08 -0400
committerDavid Robillard <d@drobilla.net>2024-09-28 11:15:15 -0400
commit50c73ad346fb63eb6d057dcc7d1351c95e12e83d (patch)
tree17e1be3b38642022e582dfde58ccced85c4ca15e /test/test_string_view.c
parent19bd977e943bf37c2c24ee0116486fa9b7611f70 (diff)
downloadzix-50c73ad346fb63eb6d057dcc7d1351c95e12e83d.tar.gz
zix-50c73ad346fb63eb6d057dcc7d1351c95e12e83d.tar.bz2
zix-50c73ad346fb63eb6d057dcc7d1351c95e12e83d.zip
Improve test allocator API
Add a simple API for setting up the failing allocator to avoid manually tinkering with its members. Conveniently, this also avoids confusing cppcheck.
Diffstat (limited to 'test/test_string_view.c')
-rw-r--r--test/test_string_view.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/test_string_view.c b/test/test_string_view.c
index 76ceab5..764edcb 100644
--- a/test/test_string_view.c
+++ b/test/test_string_view.c
@@ -95,7 +95,7 @@ test_copy(void)
ZixFailingAllocator allocator = zix_failing_allocator();
// Copying a string takes exactly one allocation
- allocator.n_remaining = 1U;
+ zix_failing_allocator_reset(&allocator, 1U);
char* const copy = zix_string_view_copy(&allocator.base, orig);
assert(copy);
@@ -103,7 +103,7 @@ test_copy(void)
zix_free(&allocator.base, copy);
// Check that allocation failure is handled gracefully
- allocator.n_remaining = 0U;
+ zix_failing_allocator_reset(&allocator, 0U);
assert(!zix_string_view_copy(&allocator.base, orig));
}