aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION2
-rw-r--r--test/osc_test.c356
2 files changed, 220 insertions, 138 deletions
diff --git a/VERSION b/VERSION
index 66c0104..56ebc9e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.131
+0.1.133
diff --git a/test/osc_test.c b/test/osc_test.c
index 64bd2b3..5d5bd74 100644
--- a/test/osc_test.c
+++ b/test/osc_test.c
@@ -932,12 +932,15 @@ static const pair_t pairs [] = {
#endif
#if !defined(_WIN32)
+static unsigned foo_sub_one = 0;
+static unsigned foo_sub_two [2] = { 0, 0 };
+static unsigned foo = 0;
+static unsigned bar = 0;
+
static void
-_one(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
- void *data)
+_one(const char *path, unsigned *flag)
{
- bool *flag = data;
- *flag = true;
+ *flag += 1;
assert(!strcmp(path, "/sub/one")
|| !strcmp(path, "/*/one")
@@ -957,11 +960,9 @@ _one(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
}
static void
-_two(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
- void *data)
+_two(const char *path, unsigned *flag)
{
- bool *flag = data;
- *flag = true;
+ *flag += 1;
assert(!strcmp(path, "/sub/two")
|| !strcmp(path, "/sub/*")
@@ -969,62 +970,143 @@ _two(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
}
static void
-_foo(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
- void *data)
+_foo(const char *path, unsigned *flag)
{
- bool *flag = data;
- *flag = true;
+ *flag += 1;
assert(!strcmp(path, "/foo")
|| !strcmp(path, "/{foo,bar}"));
}
static void
-_bar(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
- void *data)
+_bar(const char *path, unsigned *flag)
{
- bool *flag = data;
- *flag = true;
+ *flag += 1;
assert(!strcmp(path, "/bar")
|| !strcmp(path, "/{foo,bar}"));
}
-static bool foo_sub_one = false;
-static bool foo_sub_two [2] = { false, false };
-static bool foo = false;
-static bool bar = false;
+static void
+_hook_one(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
+ void *data)
+{
+ _one(path, data);
+}
+
+static void
+_hook_two(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
+ void *data)
+{
+ _two(path, data);
+}
+
+static void
+_hook_foo(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
+ void *data)
+{
+ _foo(path, data);
+}
+
+static void
+_hook_bar(const char *path, const LV2_Atom_Tuple *arguments __attribute__((unused)),
+ void *data)
+{
+ _bar(path, data);
+}
+
+static LV2_OSC_Hook hook_sub [] = {
+ { .name = "one", .method = _hook_one, .data = &foo_sub_one },
+ { .name = "two", .method = _hook_two, .data = &foo_sub_two[0] },
+ { .name = "two", .method = _hook_two, .data = &foo_sub_two[1] },
+ { .name = NULL }
+};
+
+static LV2_OSC_Hook hook_root [] = {
+ { .name = "foo", .method = _hook_foo, .data = &foo },
+ { .name = "bar", .method = _hook_bar, .data = &bar },
+ { .name = "sub", .hooks = hook_sub },
+ { .name = NULL }
+};
+
+static void
+_branch_one( const char *path, LV2_OSC_Reader *reader __attribute__((unused)),
+ LV2_OSC_Arg *arg __attribute__((unused)), void *data)
+{
+ _one(path, data);
+}
+
+static void
+_branch_two( const char *path, LV2_OSC_Reader *reader __attribute__((unused)),
+ LV2_OSC_Arg *arg __attribute__((unused)), void *data)
+{
+ _two(path, data);
+}
+
+static void
+_branch_foo( const char *path, LV2_OSC_Reader *reader __attribute__((unused)),
+ LV2_OSC_Arg *arg __attribute__((unused)), void *data)
+{
+ _foo(path, data);
+}
+
+static void
+_branch_bar( const char *path, LV2_OSC_Reader *reader __attribute__((unused)),
+ LV2_OSC_Arg *arg __attribute__((unused)), void *data)
+{
+ _bar(path, data);
+}
-static LV2_OSC_Hook sub [] = {
- { .name = "one", .method = _one, .data = &foo_sub_one },
- { .name = "two", .method = _two, .data = &foo_sub_two[0] },
- { .name = "two", .method = _two, .data = &foo_sub_two[1] },
+static LV2_OSC_Tree tree_sub [] = {
+ { .name = "one", .branch = _branch_one, .data = &foo_sub_one },
+ { .name = "two", .branch = _branch_two, .data = &foo_sub_two[0] },
+ { .name = "two", .branch = _branch_two, .data = &foo_sub_two[1] },
{ .name = NULL }
};
-static LV2_OSC_Hook root [] = {
- { .name = "foo", .method = _foo, .data = &foo },
- { .name = "bar", .method = _bar, .data = &bar },
- { .name = "sub", .hooks = sub },
+static LV2_OSC_Tree tree_root [] = {
+ { .name = "foo", .branch = _branch_foo, .data = &foo },
+ { .name = "bar", .branch = _branch_bar, .data = &bar },
+ { .name = "sub", .trees = tree_sub },
{ .name = NULL }
};
static bool
_run_test_hooks_internal(const char *path)
{
- LV2_OSC_URID osc_urid;
- LV2_Atom_Forge forge;
+ foo_sub_one = foo_sub_two[0] = foo_sub_two[1] = foo = bar = false;
- lv2_osc_urid_init(&osc_urid, &map);
- lv2_atom_forge_init(&forge, &map);
+ {
+ LV2_OSC_URID osc_urid;
+ LV2_Atom_Forge forge;
- lv2_atom_forge_set_buffer(&forge, buf0, BUF_SIZE);
- assert(lv2_osc_forge_message_vararg(&forge, &osc_urid, path, ""));
+ lv2_osc_urid_init(&osc_urid, &map);
+ lv2_atom_forge_init(&forge, &map);
- foo_sub_one = foo_sub_two[0] = foo_sub_two[1] = foo = bar = false;
+ lv2_atom_forge_set_buffer(&forge, buf0, BUF_SIZE);
+ assert(lv2_osc_forge_message_vararg(&forge, &osc_urid, path, ""));
+
+ const LV2_Atom_Object *obj = (const LV2_Atom_Object *)buf0;;
+ assert(lv2_osc_unroll(&osc_urid, obj, lv2_osc_hooks, hook_root) == true);
+ }
+
+ {
+ LV2_OSC_Writer writer;
+ LV2_OSC_Reader reader;
+
+ lv2_osc_writer_initialize(&writer, buf1, BUF_SIZE);
+ assert(lv2_osc_writer_message_vararg(&writer, path, "") == true);
+
+ size_t len;
+ const uint8_t *buf = lv2_osc_writer_finalize(&writer, &len);
+ assert(buf);
+ assert(len);
+
+ lv2_osc_reader_initialize(&reader, buf, len);
+ lv2_osc_reader_match(&reader, len, tree_root);
+ }
- const LV2_Atom_Object *obj = (const LV2_Atom_Object *)buf0;;
- return lv2_osc_unroll(&osc_urid, obj, lv2_osc_hooks, root);
+ return true;
}
static int
@@ -1032,182 +1114,182 @@ _run_test_hooks()
{
{
assert(_run_test_hooks_internal("/nil") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == false);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 0);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/foo") == true);
- assert(foo == true);
- assert(bar == false);
- assert(foo_sub_one == false);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 2);
+ assert(bar == 0);
+ assert(foo_sub_one == 0);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/bar") == true);
- assert(foo == false);
- assert(bar == true);
- assert(foo_sub_one == false);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 2);
+ assert(foo_sub_one == 0);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/sub/nil") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == false);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 0);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/sub/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/sub/two") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == false);
- assert(foo_sub_two[0] == true);
- assert(foo_sub_two[1] == true);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 0);
+ assert(foo_sub_two[0] == 2);
+ assert(foo_sub_two[1] == 2);
}
{
assert(_run_test_hooks_internal("/sub/*") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == true);
- assert(foo_sub_two[1] == true);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 2);
+ assert(foo_sub_two[1] == 2);
}
{
assert(_run_test_hooks_internal("/*/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/s*/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/su*/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/sub*/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/*sub/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/*s*u*b*/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/su[ab]/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/su[a-b]/[!a-np-z]ne") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/su[!a-b]/one") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == false);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 0);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/s?b/?ne") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/s?*/*?e") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/{foo,bar}") == true);
- assert(foo == true);
- assert(bar == true);
- assert(foo_sub_one == false);
- assert(foo_sub_two[0] == false);
- assert(foo_sub_two[1] == false);
+ assert(foo == 2);
+ assert(bar == 2);
+ assert(foo_sub_one == 0);
+ assert(foo_sub_two[0] == 0);
+ assert(foo_sub_two[1] == 0);
}
{
assert(_run_test_hooks_internal("/sub/{one,two}") == true);
- assert(foo == false);
- assert(bar == false);
- assert(foo_sub_one == true);
- assert(foo_sub_two[0] == true);
- assert(foo_sub_two[1] == true);
+ assert(foo == 0);
+ assert(bar == 0);
+ assert(foo_sub_one == 2);
+ assert(foo_sub_two[0] == 2);
+ assert(foo_sub_two[1] == 2);
}
return 0;