diff options
author | David Robillard <d@drobilla.net> | 2010-10-04 18:21:08 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-10-04 18:21:08 +0000 |
commit | cef9811dac46a9d54dab0f0d82ce5c3ae032fc7c (patch) | |
tree | 632b911da25fc24b6b3d331d7ceffc22606b8e5b /ext/contexts.lv2/test.c | |
parent | 61842745ab15454ee66be54a6f3bcc148a75406f (diff) | |
download | lv2-cef9811dac46a9d54dab0f0d82ce5c3ae032fc7c.tar.xz |
Initial import of lv2plug.in universe.
Diffstat (limited to 'ext/contexts.lv2/test.c')
-rw-r--r-- | ext/contexts.lv2/test.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ext/contexts.lv2/test.c b/ext/contexts.lv2/test.c new file mode 100644 index 0000000..f55cdd6 --- /dev/null +++ b/ext/contexts.lv2/test.c @@ -0,0 +1,65 @@ +#include <stdio.h> +#include <limits.h> +#include <assert.h> +#include <unistd.h> +#include "lv2_contexts.h" + +#define TEST_ASSERT(check) do {\ + if (!(check)) {\ + fprintf(stderr, "Failure at line %d: %s\n", __LINE__, #check);\ + assert(false);\ + _exit(1);\ + }\ +} while (0) + +#define NUM_PORTS 64 + +void +print_flags(void* flags) +{ + for (int i = NUM_PORTS; i >= 0; --i) + printf((lv2_contexts_port_is_valid(flags, i)) ? "1" : "0"); + printf("\n"); +} + + +int +main() +{ + uint64_t flags = 0; + print_flags(&flags); + + lv2_contexts_set_port_valid(&flags, 16); + print_flags(&flags); + for (int i = 0; i < NUM_PORTS; ++i) { + if (i == 16) { + TEST_ASSERT(lv2_contexts_port_is_valid(&flags, i)); + } else { + TEST_ASSERT(!lv2_contexts_port_is_valid(&flags, i)); + } + } + + lv2_contexts_set_port_valid(&flags, 46); + lv2_contexts_set_port_valid(&flags, 0); + print_flags(&flags); + for (int i = 0; i < NUM_PORTS; ++i) { + if (i == 0 || i == 16 || i == 46) { + TEST_ASSERT(lv2_contexts_port_is_valid(&flags, i)); + } else { + TEST_ASSERT(!lv2_contexts_port_is_valid(&flags, i)); + } + } + + lv2_contexts_unset_port_valid(&flags, 16); + print_flags(&flags); + for (int i = 0; i < NUM_PORTS; ++i) { + if (i == 0 || i == 46) { + TEST_ASSERT(lv2_contexts_port_is_valid(&flags, i)); + } else { + TEST_ASSERT(!lv2_contexts_port_is_valid(&flags, i)); + } + } + + return 0; +} + |