commit 5da228ad7f3903cff904221f7de5949e16b41174
parent 1c993002b2c9e957cbc0271290aa6a0778b1cd8a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 18 Mar 2015 15:52:25 +0100
Test the s3d_shape_is_attached function
Diffstat:
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/s3d_scene.c b/src/s3d_scene.c
@@ -194,7 +194,7 @@ s3d_scene_create(struct s3d_device* dev, struct s3d_scene** out_scn)
res = RES_MEM_ERR;
goto error;
}
- /* Commit empty scene => the scene can be ray traced whithout any build */
+ /* Commit empty scene => the scene can be ray traced without any build */
rtcCommit(scn->rtc_scn);
exit:
@@ -230,7 +230,7 @@ s3d_scene_attach_shape(struct s3d_scene* scn, struct s3d_shape* shape)
if(!scn || !shape)
return RES_BAD_ARG;
- /* Prevent the scene_<clear|build|remove_shape> oprations */
+ /* Prevent the scene_<clear|build|remove_shape> operations */
mutex_lock(scn->lock);
/* Prevent the shape_<attach|detach|setup> operations */
mutex_rw_wlock(shape->lock);
diff --git a/src/test_s3d_scene.c b/src/test_s3d_scene.c
@@ -60,6 +60,7 @@ main(int argc, char** argv)
CHECK(s3d_scene_attach_shape(NULL, shapes[0]), RES_BAD_ARG);
CHECK(s3d_scene_attach_shape(scn, shapes[0]), RES_OK);
CHECK(s3d_scene_attach_shape(scn, shapes[0]), RES_BAD_ARG);
+
FOR_EACH(i, 1, nshapes) {
CHECK(s3d_scene_attach_shape(scn, shapes[i]), RES_OK);
CHECK(s3d_shape_ref_put(shapes[i]), RES_OK);
diff --git a/src/test_s3d_shape.c b/src/test_s3d_shape.c
@@ -40,20 +40,42 @@ main(int argc, char** argv)
struct mem_allocator allocator;
struct s3d_device* dev;
struct s3d_shape* shape;
+ struct s3d_scene* scn;
struct s3d_vertex_data attribs[4];
+ char c;
(void)argc, (void)argv;
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
CHECK(s3d_device_create(NULL, &allocator, &dev), RES_OK);
+ CHECK(s3d_scene_create(dev, &scn), RES_OK);
CHECK(s3d_shape_create_mesh(NULL, NULL), RES_BAD_ARG);
CHECK(s3d_shape_create_mesh(dev, NULL), RES_BAD_ARG);
CHECK(s3d_shape_create_mesh(NULL, &shape), RES_BAD_ARG);
CHECK(s3d_shape_create_mesh(dev, &shape), RES_OK);
+ CHECK(s3d_shape_is_attached(NULL, NULL), RES_BAD_ARG);
+ CHECK(s3d_shape_is_attached(shape, NULL), RES_BAD_ARG);
+ CHECK(s3d_shape_is_attached(NULL, &c), RES_BAD_ARG);
+ CHECK(s3d_shape_is_attached(shape, &c), RES_OK);
+ CHECK(c, 0);
+
CHECK(s3d_shape_detach(NULL), RES_BAD_ARG);
CHECK(s3d_shape_detach(shape), RES_OK);
+ CHECK(s3d_shape_is_attached(shape, &c), RES_OK);
+ CHECK(c, 0);
+
+ CHECK(s3d_scene_attach_shape(NULL, NULL), RES_BAD_ARG);
+ CHECK(s3d_scene_attach_shape(scn, NULL), RES_BAD_ARG);
+ CHECK(s3d_scene_attach_shape(NULL, shape), RES_BAD_ARG);
+ CHECK(s3d_scene_attach_shape(scn, shape), RES_OK);
+ CHECK(s3d_shape_is_attached(shape, &c), RES_OK);
+ NCHECK(c, 0);
+
+ CHECK(s3d_shape_detach(shape), RES_OK);
+ CHECK(s3d_shape_is_attached(shape, &c), RES_OK);
+ CHECK(c, 0);
attribs[0].type = S3D_FLOAT3;
attribs[0].usage = S3D_POSITION;
@@ -183,6 +205,7 @@ main(int argc, char** argv)
CHECK(s3d_shape_ref_put(shape), RES_OK);
CHECK(s3d_shape_ref_put(shape), RES_OK);
+ CHECK(s3d_scene_ref_put(scn), RES_OK);
CHECK(s3d_device_ref_put(dev), RES_OK);;
check_memory_allocator(&allocator);