aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-04-04 22:44:30 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-04-04 22:44:30 +0200
commitdf5d2c8485bb8132cd794d0f4f12128a55b77512 (patch)
tree77920a664440ccbe563ef63bafd4200885bf8e32
parentb6c55a8008f72a4ca87f6a6faabdb220c3bfce37 (diff)
downloadprops.lv2-df5d2c8485bb8132cd794d0f4f12128a55b77512.zip
props.lv2-df5d2c8485bb8132cd794d0f4f12128a55b77512.tar.gz
props.lv2-df5d2c8485bb8132cd794d0f4f12128a55b77512.tar.bz2
props.lv2-df5d2c8485bb8132cd794d0f4f12128a55b77512.tar.xz
test: extend _test_1 with more types.
-rw-r--r--VERSION2
-rw-r--r--test/props_test.c148
2 files changed, 116 insertions, 34 deletions
diff --git a/VERSION b/VERSION
index 025c316..2c88ab2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.121
+0.1.123
diff --git a/test/props_test.c b/test/props_test.c
index 3f409cc..3fa2bfd 100644
--- a/test/props_test.c
+++ b/test/props_test.c
@@ -24,14 +24,18 @@
#define PROPS_PREFIX "http://open-music-kontrollers.ch/lv2/props#"
#define PROPS_TEST_URI PROPS_PREFIX"test"
-#define MAX_NPROPS 1
+#define MAX_NPROPS 5
typedef struct _plugstate_t plugstate_t;
typedef struct _urid_t urid_t;
typedef void (*test_t)(props_t *props);
struct _plugstate_t {
- uint32_t foo;
+ int32_t b32;
+ int32_t i32;
+ int64_t i64;
+ float f32;
+ double f64;
};
struct _urid_t {
@@ -40,7 +44,16 @@ struct _urid_t {
};
static urid_t urids [MAX_URIDS];
-static LV2_URID urid;
+static LV2_URID nurid;
+
+static void
+_map_deinit()
+{
+ for(urid_t *itm=urids; itm->urid; itm++)
+ {
+ free(itm->uri);
+ }
+}
static LV2_URID
_map(LV2_URID_Map_Handle instance __attribute__((unused)), const char *uri)
@@ -49,14 +62,17 @@ _map(LV2_URID_Map_Handle instance __attribute__((unused)), const char *uri)
for(itm=urids; itm->urid; itm++)
{
if(!strcmp(itm->uri, uri))
+ {
return itm->urid;
+ }
}
- assert(urid + 1 < MAX_URIDS);
+ assert(nurid + 1 < MAX_URIDS);
// create new
- itm->urid = ++urid;
+ itm->urid = ++nurid;
itm->uri = strdup(uri);
+ assert(itm->uri);
return itm->urid;
}
@@ -68,9 +84,29 @@ static LV2_URID_Map map = {
static const props_def_t defs [MAX_NPROPS] = {
{
- .property = PROPS_PREFIX"foo",
- .offset = offsetof(plugstate_t, foo),
+ .property = PROPS_PREFIX"b32",
+ .offset = offsetof(plugstate_t, b32),
+ .type = LV2_ATOM__Bool
+ },
+ {
+ .property = PROPS_PREFIX"i32",
+ .offset = offsetof(plugstate_t, i32),
.type = LV2_ATOM__Int
+ },
+ {
+ .property = PROPS_PREFIX"i64",
+ .offset = offsetof(plugstate_t, i64),
+ .type = LV2_ATOM__Long
+ },
+ {
+ .property = PROPS_PREFIX"f32",
+ .offset = offsetof(plugstate_t, f32),
+ .type = LV2_ATOM__Float
+ },
+ {
+ .property = PROPS_PREFIX"f64",
+ .offset = offsetof(plugstate_t, f64),
+ .type = LV2_ATOM__Double
}
};
@@ -82,26 +118,77 @@ _test_1(props_t *props)
{
assert(props);
- const LV2_URID property = props_map(props, PROPS_PREFIX"foo");
- assert(property != 0);
-
- props_impl_t *impl = _props_impl_get(props, property);
- assert(impl);
-
- assert(impl->property == property);
- assert(impl->type != 0); //FIXME
- assert(impl->access != 0); //FIXME
-
- assert(impl->value.size == sizeof(state.foo));
- assert(impl->value.body == &state.foo);
-
- assert(impl->stash.size == sizeof(stash.foo));
- assert(impl->stash.body == &stash.foo);
-
- assert(impl->def == &defs[0]);
-
- assert(atomic_load(&impl->state) == PROP_STATE_NONE);
- assert(impl->stashing == false);
+ for(unsigned i = 0; i < MAX_NPROPS; i++)
+ {
+ const props_def_t *def = &defs[i];
+
+ const LV2_URID property = props_map(props, def->property);
+ assert(property != 0);
+
+ props_impl_t *impl = _props_impl_get(props, property);
+ assert(impl);
+
+ const LV2_URID type = map.map(map.handle, def->type);
+ const LV2_URID access = map.map(map.handle, def->access
+ ? def->access : LV2_PATCH__writable);
+
+ assert(impl->property == property);
+ assert(impl->type == type);
+ assert(impl->access == access);
+
+ assert(impl->def == def);
+
+ assert(atomic_load(&impl->state) == PROP_STATE_NONE);
+ assert(impl->stashing == false);
+
+ switch(i)
+ {
+ case 0:
+ {
+ assert(impl->value.size == sizeof(state.b32));
+ assert(impl->value.body == &state.b32);
+
+ assert(impl->stash.size == sizeof(stash.b32));
+ assert(impl->stash.body == &stash.b32);
+ } break;
+ case 1:
+ {
+ assert(impl->value.size == sizeof(state.i32));
+ assert(impl->value.body == &state.i32);
+
+ assert(impl->stash.size == sizeof(stash.i32));
+ assert(impl->stash.body == &stash.i32);
+ } break;
+ case 2:
+ {
+ assert(impl->value.size == sizeof(state.i64));
+ assert(impl->value.body == &state.i64);
+
+ assert(impl->stash.size == sizeof(stash.i64));
+ assert(impl->stash.body == &stash.i64);
+ } break;
+ case 3:
+ {
+ assert(impl->value.size == sizeof(state.f32));
+ assert(impl->value.body == &state.f32);
+
+ assert(impl->stash.size == sizeof(stash.f32));
+ assert(impl->stash.body == &stash.f32);
+ } break;
+ case 4:
+ {
+ assert(impl->value.size == sizeof(state.f64));
+ assert(impl->value.body == &state.f64);
+
+ assert(impl->stash.size == sizeof(stash.f64));
+ assert(impl->stash.body == &stash.f64);
+ } break;
+ default:
+ {
+ assert(false);
+ } break;
+ }
+ }
}
static const test_t tests [] = {
@@ -126,12 +213,7 @@ main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
(*test)(&props);
}
- for(unsigned i=0; i<urid; i++)
- {
- urid_t *itm = &urids[i];
-
- free(itm->uri);
- }
+ _map_deinit();
return 0;
}