commit 02121923dd7f34fc09118710acc2b9e5343d0cd3
parent c13413e928a413bb282b60cfa3a85f55e5a42693
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 6 Sep 2022 10:05:50 +0200
Une new header file in test1
Diffstat:
3 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -73,7 +73,8 @@ rcmake_setup_devel(scad StarCAD ${VERSION} star/scad_version.h)
if(NOT NO_TEST)
function(build_test _name)
add_executable(${_name}
- ${SCAD_SOURCE_DIR}/${_name}.c)
+ ${SCAD_SOURCE_DIR}/${_name}.c
+ ${SCAD_SOURCE_DIR}/test_common.h)
target_link_libraries(${_name} scad RSys)
set(_libraries ${ARGN})
foreach(_lib ${_libraries})
diff --git a/src/test1.c b/src/test1.c
@@ -15,6 +15,7 @@
#include "scad.h"
#include "scad_geometry.h"
+#include "test_common.h"
#include <rsys/rsys.h>
#include <rsys/math.h>
@@ -22,19 +23,6 @@
#include <stdlib.h>
-#define OK(Expr) if((res = (Expr)) != RES_OK) goto error; else (void)0
-#define BAD(Expr) if((res = (Expr)) != RES_BAD_ARG) goto error; else (void)0
-
-static void
-check_memory_allocator(struct mem_allocator* allocator) {
- if(MEM_ALLOCATED_SIZE(allocator)) {
- char dump[4096];
- MEM_DUMP(allocator, dump, sizeof(dump)/sizeof(char));
- fprintf(stderr, "%s\n", dump);
- FATAL("Memory leaks.\n");
- }
-}
-
int
main(int argc, char* argv[])
{
diff --git a/src/test_common.h b/src/test_common.h
@@ -0,0 +1,37 @@
+/* Copyright (C) 2022 |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 "scad.h"
+#include "scad_geometry.h"
+
+#include <rsys/rsys.h>
+#include <rsys/math.h>
+#include <rsys/mem_allocator.h>
+
+#include <stdlib.h>
+
+#define OK(Expr) CHK(RES_OK == (Expr))
+#define BAD(Expr) CHK(RES_BAD_ARG == (Expr))
+
+static void
+check_memory_allocator(struct mem_allocator* allocator) {
+ if(MEM_ALLOCATED_SIZE(allocator)) {
+ char dump[4096];
+ MEM_DUMP(allocator, dump, sizeof(dump)/sizeof(char));
+ fprintf(stderr, "%s\n", dump);
+ FATAL("Memory leaks.\n");
+ }
+}
+