diff options
author | David Robillard <d@drobilla.net> | 2012-02-08 04:56:24 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-02-08 04:56:24 +0000 |
commit | ed78bbe5ba12be1f9bcc736f14c51da6b4f639f3 (patch) | |
tree | 653a2dfe33f3923da45a38fc04ed2106f93528f3 /lv2/lv2plug.in/ns/ext/contexts/test.c | |
parent | b617875c6f3ad439d25ae166da79df839ebfdc71 (diff) | |
download | lv2-ed78bbe5ba12be1f9bcc736f14c51da6b4f639f3.tar.xz |
Rearrange tree so top level can be used as an include path for standard style LV2 includes.
Diffstat (limited to 'lv2/lv2plug.in/ns/ext/contexts/test.c')
-rw-r--r-- | lv2/lv2plug.in/ns/ext/contexts/test.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lv2/lv2plug.in/ns/ext/contexts/test.c b/lv2/lv2plug.in/ns/ext/contexts/test.c new file mode 100644 index 0000000..ca41a10 --- /dev/null +++ b/lv2/lv2plug.in/ns/ext/contexts/test.c @@ -0,0 +1,67 @@ +#include <stdio.h> +#include <stdint.h> +#include <stdbool.h> +#include <limits.h> +#include <assert.h> +#include <unistd.h> +#include "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; +} + |