summaryrefslogtreecommitdiffstats
path: root/test/test_args.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-11-25 09:55:27 -0500
committerDavid Robillard <d@drobilla.net>2022-11-25 10:08:49 -0500
commit0569a7ad70a82d68548bbe4cf79bcc64d5f9878d (patch)
tree1eefbd728f33f31b0d270b5c0e76754a6ced7913 /test/test_args.h
parent112fa18bfa293629ccb90fbd952aa6e61398da80 (diff)
downloadzix-0569a7ad70a82d68548bbe4cf79bcc64d5f9878d.tar.gz
zix-0569a7ad70a82d68548bbe4cf79bcc64d5f9878d.tar.bz2
zix-0569a7ad70a82d68548bbe4cf79bcc64d5f9878d.zip
Constrain test parameters to reasonable limits
Diffstat (limited to 'test/test_args.h')
-rw-r--r--test/test_args.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_args.h b/test/test_args.h
new file mode 100644
index 0000000..e212a94
--- /dev/null
+++ b/test/test_args.h
@@ -0,0 +1,18 @@
+// Copyright 2022 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef ZIX_TEST_ARGS_H
+#define ZIX_TEST_ARGS_H
+
+#include <stddef.h>
+#include <stdlib.h>
+
+static inline size_t
+zix_test_size_arg(const char* const string, const size_t min, const size_t max)
+{
+ const size_t size = strtoul(string, NULL, 10);
+
+ return size < min ? min : size > max ? max : size;
+}
+
+#endif // ZIX_TEST_ARGS_H