diff options
author | sanine <sanine.not@pm.me> | 2023-02-05 13:18:12 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-02-05 13:18:12 -0600 |
commit | 1ba558a9c92cd61f05a695dcd2e6f75215c0c584 (patch) | |
tree | b82c4949b47321faf3ca2912cf44fde2526c1c58 /src | |
parent | 5c81c2d2eef132923a75da05efef160adcf95c86 (diff) |
begin implementing kai_read_source()
Diffstat (limited to 'src')
-rw-r--r-- | src/geometry/geometry.c | 11 | ||||
-rw-r--r-- | src/geometry/geometry.h | 1 | ||||
-rw-r--r-- | src/geometry/geometry.test.c | 45 |
3 files changed, 57 insertions, 0 deletions
diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index c3eb40c..42e7970 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -98,3 +98,14 @@ int kai_read_accessor(struct ka_accessor_t *dest, struct kai_tag_t *src) return 0; } + + +int kai_read_source(struct ka_source_t *dest, struct kai_tag_t *src) +{ + CHECK_TAG_TYPE("source"); + + char *id = kai_tag_attr_to_dup(src, "id"); + if (id == NULL) { return -1; } + + return 0; +} diff --git a/src/geometry/geometry.h b/src/geometry/geometry.h index daa883d..a0c122c 100644 --- a/src/geometry/geometry.h +++ b/src/geometry/geometry.h @@ -7,5 +7,6 @@ int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src); int kai_read_param(struct ka_param_t *dest, struct kai_tag_t *src); int kai_read_accessor(struct ka_accessor_t *dest, struct kai_tag_t *src); +int kai_read_source(struct ka_source_t *dest, struct kai_tag_t *src); #endif diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c index 2c172f2..fd1f379 100644 --- a/src/geometry/geometry.test.c +++ b/src/geometry/geometry.test.c @@ -178,5 +178,50 @@ LILY_TEST("parse accessor") #include LILY_PUSH_TEST() +LILY_TEST("fail to read non-source tag") +{ + struct kai_tag_t *t = kai_parse_string( + "<tag />" + ); + + struct ka_source_t source; + int result = kai_read_source(&source, t); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("fail to read source tag with no specified id") +{ + struct kai_tag_t *t = kai_parse_string( + "<source />" + ); + + struct ka_source_t source; + int result = kai_read_source(&source, t); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("read source correctly") +{ + struct kai_tag_t *t = kai_parse_string( + "<source id=\"source\">" + " <float_array count=\"1\">0.0</float_array>" + " <technique_common>" + " <accessor count=\"1\" id=\"xxx\">" + " <param type=\"float\" />" + " </accessor>" + " </technique_common>" + "</source>" + ); +} + + #define LILY_FILE_END #include LILY_REGISTER_TESTS() |