aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-04-05 13:07:41 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-04-05 13:07:41 +0200
commita8921f508b85cc6171c1c130a2b6026d3af7e51c (patch)
tree8cc0b36d55f20beb5cc00cf09588e8bec4d883cf
parent6d32f136ea7730e50208fc4babdfd4397e3a869f (diff)
downloadprops.lv2-a8921f508b85cc6171c1c130a2b6026d3af7e51c.zip
props.lv2-a8921f508b85cc6171c1c130a2b6026d3af7e51c.tar.gz
props.lv2-a8921f508b85cc6171c1c130a2b6026d3af7e51c.tar.bz2
props.lv2-a8921f508b85cc6171c1c130a2b6026d3af7e51c.tar.xz
test: add more types to state.
-rw-r--r--VERSION2
-rw-r--r--test/props_test.c181
2 files changed, 170 insertions, 13 deletions
diff --git a/VERSION b/VERSION
index 5076ee8..74799d8 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.125
+0.1.127
diff --git a/test/props_test.c b/test/props_test.c
index 6b32d64..e12a0db 100644
--- a/test/props_test.c
+++ b/test/props_test.c
@@ -20,12 +20,13 @@
#include <props.h>
#define MAX_URIDS 512
+#define STR_SIZE 32
+#define CHUNK_SIZE 16
+#define VEC_SIZE 13
#define PROPS_PREFIX "http://open-music-kontrollers.ch/lv2/props#"
#define PROPS_TEST_URI PROPS_PREFIX"test"
-#define MAX_NPROPS 5
-
typedef struct _plugstate_t plugstate_t;
typedef struct _urid_t urid_t;
typedef struct _handle_t handle_t;
@@ -37,6 +38,17 @@ struct _plugstate_t {
int64_t i64;
float f32;
double f64;
+ uint32_t urid;
+ char str [STR_SIZE];
+ char uri [STR_SIZE];
+ char path [STR_SIZE];
+ uint8_t chunk [CHUNK_SIZE];
+ LV2_Atom_Literal_Body lit;
+ char lit_body [STR_SIZE];
+ LV2_Atom_Vector_Body vec;
+ int32_t vec_body [VEC_SIZE];
+ LV2_Atom_Object_Body obj; //FIXME
+ LV2_Atom_Sequence_Body seq; //FIXME
};
struct _urid_t {
@@ -44,6 +56,25 @@ struct _urid_t {
char *uri;
};
+enum {
+ PROP_b32 = 0,
+ PROP_i32,
+ PROP_i64,
+ PROP_f32,
+ PROP_f64,
+ PROP_urid,
+ PROP_str,
+ PROP_uri,
+ PROP_path,
+ PROP_chunk,
+ PROP_lit,
+ PROP_vec,
+ PROP_obj,
+ PROP_seq,
+
+ MAX_NPROPS
+};
+
struct _handle_t {
PROPS_T(props, MAX_NPROPS);
plugstate_t state;
@@ -77,30 +108,83 @@ _map(LV2_URID_Map_Handle instance, const char *uri)
}
static const props_def_t defs [MAX_NPROPS] = {
- {
+ [PROP_b32] = {
.property = PROPS_PREFIX"b32",
.offset = offsetof(plugstate_t, b32),
.type = LV2_ATOM__Bool
},
- {
+ [PROP_i32] = {
.property = PROPS_PREFIX"i32",
.offset = offsetof(plugstate_t, i32),
.type = LV2_ATOM__Int
},
- {
+ [PROP_i64] = {
.property = PROPS_PREFIX"i64",
.offset = offsetof(plugstate_t, i64),
.type = LV2_ATOM__Long
},
- {
+ [PROP_f32] = {
.property = PROPS_PREFIX"f32",
.offset = offsetof(plugstate_t, f32),
.type = LV2_ATOM__Float
},
- {
+ [PROP_f64] = {
.property = PROPS_PREFIX"f64",
.offset = offsetof(plugstate_t, f64),
.type = LV2_ATOM__Double
+ },
+ [PROP_urid] = {
+ .property = PROPS_PREFIX"urid",
+ .offset = offsetof(plugstate_t, urid),
+ .type = LV2_ATOM__URID
+ },
+ [PROP_str] = {
+ .property = PROPS_PREFIX"str",
+ .offset = offsetof(plugstate_t, str),
+ .type = LV2_ATOM__String,
+ .max_size = STR_SIZE
+ },
+ [PROP_uri] = {
+ .property = PROPS_PREFIX"uri",
+ .offset = offsetof(plugstate_t, uri),
+ .type = LV2_ATOM__URI,
+ .max_size = STR_SIZE
+ },
+ [PROP_path] = {
+ .property = PROPS_PREFIX"path",
+ .offset = offsetof(plugstate_t, path),
+ .type = LV2_ATOM__Path,
+ .max_size = STR_SIZE
+ },
+ [PROP_chunk] = {
+ .property = PROPS_PREFIX"chunk",
+ .offset = offsetof(plugstate_t, chunk),
+ .type = LV2_ATOM__Chunk,
+ .max_size = CHUNK_SIZE
+ },
+ [PROP_lit] = {
+ .property = PROPS_PREFIX"lit",
+ .offset = offsetof(plugstate_t, lit),
+ .type = LV2_ATOM__Literal,
+ .max_size = sizeof(LV2_Atom_Literal_Body) + STR_SIZE
+ },
+ [PROP_vec] = {
+ .property = PROPS_PREFIX"vec",
+ .offset = offsetof(plugstate_t, vec),
+ .type = LV2_ATOM__Literal,
+ .max_size = sizeof(LV2_Atom_Vector_Body) + VEC_SIZE*sizeof(int32_t)
+ },
+ [PROP_obj] = {
+ .property = PROPS_PREFIX"obj",
+ .offset = offsetof(plugstate_t, obj),
+ .type = LV2_ATOM__Object,
+ .max_size = sizeof(LV2_Atom_Object_Body) + 0 //FIXME
+ },
+ [PROP_seq] = {
+ .property = PROPS_PREFIX"seq",
+ .offset = offsetof(plugstate_t, seq),
+ .type = LV2_ATOM__Sequence,
+ .max_size = sizeof(LV2_Atom_Sequence_Body) + 0 //FIXME
}
};
@@ -120,6 +204,7 @@ _test_1(handle_t *handle)
const LV2_URID property = props_map(props, def->property);
assert(property != 0);
+ assert(property == map->map(map->handle, def->property));
props_impl_t *impl = _props_impl_get(props, property);
assert(impl);
@@ -139,7 +224,7 @@ _test_1(handle_t *handle)
switch(i)
{
- case 0:
+ case PROP_b32:
{
assert(impl->value.size == sizeof(state->b32));
assert(impl->value.body == &state->b32);
@@ -147,7 +232,7 @@ _test_1(handle_t *handle)
assert(impl->stash.size == sizeof(stash->b32));
assert(impl->stash.body == &stash->b32);
} break;
- case 1:
+ case PROP_i32:
{
assert(impl->value.size == sizeof(state->i32));
assert(impl->value.body == &state->i32);
@@ -155,7 +240,7 @@ _test_1(handle_t *handle)
assert(impl->stash.size == sizeof(stash->i32));
assert(impl->stash.body == &stash->i32);
} break;
- case 2:
+ case PROP_i64:
{
assert(impl->value.size == sizeof(state->i64));
assert(impl->value.body == &state->i64);
@@ -163,7 +248,7 @@ _test_1(handle_t *handle)
assert(impl->stash.size == sizeof(stash->i64));
assert(impl->stash.body == &stash->i64);
} break;
- case 3:
+ case PROP_f32:
{
assert(impl->value.size == sizeof(state->f32));
assert(impl->value.body == &state->f32);
@@ -171,7 +256,7 @@ _test_1(handle_t *handle)
assert(impl->stash.size == sizeof(stash->f32));
assert(impl->stash.body == &stash->f32);
} break;
- case 4:
+ case PROP_f64:
{
assert(impl->value.size == sizeof(state->f64));
assert(impl->value.body == &state->f64);
@@ -179,6 +264,78 @@ _test_1(handle_t *handle)
assert(impl->stash.size == sizeof(stash->f64));
assert(impl->stash.body == &stash->f64);
} break;
+ case PROP_urid:
+ {
+ assert(impl->value.size == sizeof(state->urid));
+ assert(impl->value.body == &state->urid);
+
+ assert(impl->stash.size == sizeof(stash->urid));
+ assert(impl->stash.body == &stash->urid);
+ } break;
+ case PROP_str:
+ {
+ assert(impl->value.size == 0);
+ assert(impl->value.body == &state->str);
+
+ assert(impl->stash.size == 0);
+ assert(impl->stash.body == &stash->str);
+ } break;
+ case PROP_uri:
+ {
+ assert(impl->value.size == 0);
+ assert(impl->value.body == &state->uri);
+
+ assert(impl->stash.size == 0);
+ assert(impl->stash.body == &stash->uri);
+ } break;
+ case PROP_path:
+ {
+ assert(impl->value.size == 0);
+ assert(impl->value.body == &state->path);
+
+ assert(impl->stash.size == 0);
+ assert(impl->stash.body == &stash->path);
+ } break;
+ case PROP_chunk:
+ {
+ assert(impl->value.size == 0);
+ assert(impl->value.body == &state->chunk);
+
+ assert(impl->stash.size == 0);
+ assert(impl->stash.body == &stash->chunk);
+ } break;
+ case PROP_lit:
+ {
+ assert(impl->value.size == sizeof(state->lit));
+ assert(impl->value.body == &state->lit);
+
+ assert(impl->stash.size == sizeof(stash->lit));
+ assert(impl->stash.body == &stash->lit);
+ } break;
+ case PROP_vec:
+ {
+ assert(impl->value.size == sizeof(state->vec));
+ assert(impl->value.body == &state->vec);
+
+ assert(impl->stash.size == sizeof(stash->vec));
+ assert(impl->stash.body == &stash->vec);
+ } break;
+ case PROP_obj:
+ {
+ assert(impl->value.size == sizeof(state->obj));
+ assert(impl->value.body == &state->obj);
+
+ assert(impl->stash.size == sizeof(stash->obj));
+ assert(impl->stash.body == &stash->obj);
+ } break;
+ case PROP_seq:
+ {
+ assert(impl->value.size == sizeof(state->seq));
+ assert(impl->value.body == &state->seq);
+
+ assert(impl->stash.size == sizeof(stash->seq));
+ assert(impl->stash.body == &stash->seq);
+ } break;
default:
{
assert(false);