commit 881667a688a0ad186c14e83955c945a013d4c97d
parent 09a981163886fdfb7c5c402f2ecc1a604d00d8b2
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 30 Apr 2018 15:40:17 +0200
Add a load_from_file test
Diffstat:
2 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -84,6 +84,8 @@ if(NOT NO_TEST)
new_test(test_htcop)
new_test(test_htcop_load)
+
+ build_test(test_htcop_load_from_file)
endif()
################################################################################
diff --git a/src/test_htcop_load_from_file.c b/src/test_htcop_load_from_file.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 2018 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "htcop.h"
+#include "test_htcop_utils.h"
+
+int
+main(int argc, char** argv)
+{
+ struct htcop* htcop = NULL;
+ struct htcop_desc desc = HTCOP_DESC_NULL;
+ size_t i, n;
+
+ if(argc < 2) {
+ fprintf(stderr, "Usage: %s HTCOP_FILE\n", argv[0]);
+ return -1;
+ }
+
+ CHK(htcop_create(NULL, &mem_default_allocator, 1, &htcop) == RES_OK);
+ CHK(htcop_load(htcop, argv[1]) == RES_OK);
+
+ CHK(htcop_get_desc(htcop, &desc) == RES_OK);
+
+ printf("pagesize: %lu\n", (unsigned long)desc.pagesize);
+ printf("irregular Z: %i\n", desc.irregular_z);
+ printf("#X: %lu; #Y: %lu; #Z: %lu; #times: %lu\n",
+ desc.spatial_definition[0],
+ desc.spatial_definition[1],
+ desc.spatial_definition[2],
+ desc.time_definition);
+ printf("lower pos: %g %g %g\n", SPLIT3(desc.lower));
+ printf("voxel size: %g %g ", desc.vxsz_x, desc.vxsz_y);
+ if(!desc.irregular_z) {
+ printf("%g\n", desc.vxsz_z[0]);
+ } else {
+ printf("{");
+ FOR_EACH(i, 0, desc.spatial_definition[2]) {
+ printf("%g", desc.vxsz_z[i]);
+ if(i != desc.spatial_definition[2]-1) printf(", ");
+ }
+ printf("}");
+ }
+
+ n = desc.spatial_definition[0]
+ * desc.spatial_definition[1]
+ * desc.spatial_definition[2]
+ * desc.time_definition;
+
+ printf("RVT:\n");
+ FOR_EACH(i, 0, n) {
+ printf("%g\n", desc.RVT[i]);
+ }
+
+ printf("RCT:\n");
+ FOR_EACH(i, 0, n) {
+ printf("%g\n", desc.RCT[i]);
+ }
+
+ CHK(htcop_ref_put(htcop) == RES_OK);
+ check_memory_allocator(&mem_default_allocator);
+ CHK(mem_allocated_size() == 0);
+ return 0;
+}