tests: include C sources directly
This avoids to declare prototypes of the test_xxx() functions
This commit is contained in:
parent
806e2121c3
commit
eb9719ef16
@ -28,10 +28,6 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp)
|
||||
# test_core
|
||||
set(GMIO_TEST_CORE_SRC
|
||||
main_test_core.c
|
||||
test_core.c
|
||||
test_core_benchmark_fast_atof.c
|
||||
test_core_internal.c
|
||||
test_core_platform.c
|
||||
core_utils.c
|
||||
stream_buffer.c
|
||||
../benchmarks/commons/benchmark_tools.c)
|
||||
@ -53,11 +49,6 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/models
|
||||
set(GMIO_TEST_STL_SRC
|
||||
main_test_stl.c
|
||||
stl_testcases.c
|
||||
test_stl_internal.c
|
||||
test_stl_infos.c
|
||||
test_stl_io.c
|
||||
test_stl_triangle.c
|
||||
test_stlb_header.c
|
||||
core_utils.c
|
||||
stl_utils.c)
|
||||
if(GMIO_BUILD_SHARED_LIBS)
|
||||
|
@ -15,21 +15,10 @@
|
||||
|
||||
#include "utest_lib.h"
|
||||
|
||||
const char* test_core__buffer();
|
||||
const char* test_core__endian();
|
||||
const char* test_core__error();
|
||||
const char* test_core__stream();
|
||||
|
||||
const char* test_internal__byte_swap();
|
||||
const char* test_internal__byte_codec();
|
||||
const char* test_internal__fast_atof();
|
||||
const char* test_internal__safe_cast();
|
||||
const char* test_internal__stringstream();
|
||||
const char* test_internal__string_utils();
|
||||
const char* test_internal__benchmark_gmio_fast_atof();
|
||||
|
||||
const char* test_platform__global_h();
|
||||
const char* test_platform__compiler();
|
||||
#include "test_core.c"
|
||||
#include "test_core_benchmark_fast_atof.c"
|
||||
#include "test_core_internal.c"
|
||||
#include "test_core_platform.c"
|
||||
|
||||
const char* all_tests()
|
||||
{
|
||||
@ -40,6 +29,9 @@ const char* all_tests()
|
||||
UTEST_RUN(test_core__error);
|
||||
UTEST_RUN(test_core__stream);
|
||||
|
||||
UTEST_RUN(test_platform__global_h);
|
||||
UTEST_RUN(test_platform__compiler);
|
||||
|
||||
UTEST_RUN(test_internal__byte_swap);
|
||||
UTEST_RUN(test_internal__byte_codec);
|
||||
UTEST_RUN(test_internal__fast_atof);
|
||||
@ -48,9 +40,6 @@ const char* all_tests()
|
||||
UTEST_RUN(test_internal__string_utils);
|
||||
UTEST_RUN(test_internal__benchmark_gmio_fast_atof);
|
||||
|
||||
UTEST_RUN(test_platform__global_h);
|
||||
UTEST_RUN(test_platform__compiler);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
UTEST_MAIN(all_tests)
|
||||
|
@ -17,25 +17,11 @@
|
||||
|
||||
#include "../src/gmio_core/memblock.h"
|
||||
|
||||
const char* test_stl_coords_packing();
|
||||
const char* test_stl_triangle_packing();
|
||||
const char* test_stl_triangle_compute_normal();
|
||||
|
||||
const char* test_stl_internal__rw_common();
|
||||
|
||||
const char* test_stl_infos();
|
||||
|
||||
const char* test_stl_read();
|
||||
const char* test_stl_read_multi_solid();
|
||||
const char* test_stla_write();
|
||||
const char* test_stlb_read();
|
||||
const char* test_stlb_write();
|
||||
const char* test_stlb_header_write();
|
||||
|
||||
const char* test_stlb_header_str();
|
||||
const char* test_stlb_header_to_printable_str();
|
||||
|
||||
void generate_stlb_tests_models();
|
||||
#include "test_stl_infos.c"
|
||||
#include "test_stl_internal.c"
|
||||
#include "test_stl_io.c"
|
||||
#include "test_stl_triangle.c"
|
||||
#include "test_stlb_header.c"
|
||||
|
||||
/* Static memblock */
|
||||
struct gmio_memblock gmio_memblock_for_tests()
|
||||
|
@ -23,12 +23,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static struct gmio_memblock buffer_ctor()
|
||||
static struct gmio_memblock __tc__buffer_ctor()
|
||||
{
|
||||
return gmio_memblock_calloc(4, 256);
|
||||
}
|
||||
|
||||
const char* test_core__buffer()
|
||||
static const char* test_core__buffer()
|
||||
{
|
||||
/* gmio_memblock_calloc() */
|
||||
{
|
||||
@ -68,14 +68,14 @@ const char* test_core__buffer()
|
||||
/* default ctor */
|
||||
{
|
||||
UTEST_ASSERT(gmio_memblock_default_constructor() != NULL);
|
||||
gmio_memblock_set_default_constructor(&buffer_ctor);
|
||||
UTEST_ASSERT(gmio_memblock_default_constructor() == &buffer_ctor);
|
||||
gmio_memblock_set_default_constructor(&__tc__buffer_ctor);
|
||||
UTEST_ASSERT(gmio_memblock_default_constructor() == &__tc__buffer_ctor);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_core__endian()
|
||||
static const char* test_core__endian()
|
||||
{
|
||||
UTEST_ASSERT(gmio_host_endianness() == GMIO_ENDIANNESS_HOST);
|
||||
GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(4127)
|
||||
@ -86,7 +86,7 @@ GMIO_PRAGMA_MSVC_WARNING_POP()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_core__error()
|
||||
static const char* test_core__error()
|
||||
{
|
||||
UTEST_ASSERT(gmio_no_error(GMIO_ERROR_OK));
|
||||
UTEST_ASSERT(!gmio_error(GMIO_ERROR_OK));
|
||||
@ -97,14 +97,12 @@ const char* test_core__error()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_core__stream()
|
||||
static const char* test_core__stream()
|
||||
{
|
||||
{
|
||||
const struct gmio_stream null_stream = gmio_stream_null();
|
||||
const uint8_t null_bytes[sizeof(struct gmio_stream)] = {0};
|
||||
UTEST_ASSERT(memcmp(&null_stream, &null_bytes, sizeof(struct gmio_stream))
|
||||
== 0);
|
||||
}
|
||||
const struct gmio_stream null_stream = gmio_stream_null();
|
||||
const uint8_t null_bytes[sizeof(struct gmio_stream)] = {0};
|
||||
UTEST_ASSERT(memcmp(&null_stream, &null_bytes, sizeof(struct gmio_stream))
|
||||
== 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -23,32 +23,32 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
static float float_array[1024] = {0};
|
||||
static float __tc__float_array[1024] = {0};
|
||||
|
||||
static void test_internal__fill_float_array()
|
||||
static void __tc__fill_float_array()
|
||||
{
|
||||
const float fmax = 1e6;
|
||||
size_t i;
|
||||
|
||||
srand((unsigned)time(NULL));
|
||||
|
||||
for (i = 0; i < GMIO_ARRAY_SIZE(float_array); ++i) {
|
||||
for (i = 0; i < GMIO_ARRAY_SIZE(__tc__float_array); ++i) {
|
||||
const double dsign = (i % 2) == 0 ? 1. : -1.;
|
||||
const double drand = (double)rand();
|
||||
const double drand_max = (double)RAND_MAX;
|
||||
const double dmax = (double)fmax;
|
||||
float_array[i] = (float)(dsign * (drand / drand_max) * dmax);
|
||||
__tc__float_array[i] = (float)(dsign * (drand / drand_max) * dmax);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_internal__run_atof(float (*func_atof)(const char*))
|
||||
static void __tc__run_atof(float (*func_atof)(const char*))
|
||||
{
|
||||
char strbuff[512] = {0};
|
||||
size_t iter;
|
||||
for (iter = 0; iter < 250; ++iter) {
|
||||
size_t i;
|
||||
for (i = 0; i < GMIO_ARRAY_SIZE(float_array); ++i) {
|
||||
const float f = float_array[i];
|
||||
for (i = 0; i < GMIO_ARRAY_SIZE(__tc__float_array); ++i) {
|
||||
const float f = __tc__float_array[i];
|
||||
float fres = 0.f;
|
||||
gmio_snprintf(strbuff, sizeof(strbuff), "%f", f);
|
||||
fres = func_atof(strbuff);
|
||||
@ -58,34 +58,36 @@ static void test_internal__run_atof(float (*func_atof)(const char*))
|
||||
}
|
||||
}
|
||||
|
||||
static float float_strtod(const char* str)
|
||||
static float __tc__float_strtod(const char* str)
|
||||
{
|
||||
return (float)strtod(str, NULL);
|
||||
}
|
||||
|
||||
static void benchmark_fast_atof(const void* arg)
|
||||
static void __tc__benchmark_fast_atof(const void* arg)
|
||||
{
|
||||
GMIO_UNUSED(arg);
|
||||
test_internal__run_atof(&fast_atof);
|
||||
__tc__run_atof(&fast_atof);
|
||||
}
|
||||
|
||||
static void benchmark_strtod(const void* arg)
|
||||
static void __tc__benchmark_strtod(const void* arg)
|
||||
{
|
||||
GMIO_UNUSED(arg);
|
||||
test_internal__run_atof(&float_strtod);
|
||||
__tc__run_atof(&__tc__float_strtod);
|
||||
}
|
||||
|
||||
const char* test_internal__benchmark_gmio_fast_atof()
|
||||
static const char* test_internal__benchmark_gmio_fast_atof()
|
||||
{
|
||||
struct benchmark_cmp_arg bmk_arg[] = {
|
||||
{ "str->float", &benchmark_fast_atof, NULL, &benchmark_strtod, NULL },
|
||||
{ "str->float",
|
||||
&__tc__benchmark_fast_atof, NULL,
|
||||
&__tc__benchmark_strtod, NULL },
|
||||
{0}
|
||||
};
|
||||
struct benchmark_cmp_result bmk_res[] = { {0}, {0} };
|
||||
const struct benchmark_cmp_result_header header = { "fast_atof", "strtod" };
|
||||
struct benchmark_cmp_result_array bmk_res_array = {0};
|
||||
|
||||
test_internal__fill_float_array();
|
||||
__tc__fill_float_array();
|
||||
benchmark_cmp_batch(2, bmk_arg, bmk_res, NULL, NULL);
|
||||
bmk_res_array.ptr = bmk_res;
|
||||
bmk_res_array.count = GMIO_ARRAY_SIZE(bmk_res) - 1;
|
||||
|
@ -31,14 +31,14 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* test_internal__byte_swap()
|
||||
static const char* test_internal__byte_swap()
|
||||
{
|
||||
UTEST_ASSERT(gmio_uint16_bswap(0x1122) == 0x2211);
|
||||
UTEST_ASSERT(gmio_uint32_bswap(0x11223344) == 0x44332211);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_internal__byte_codec()
|
||||
static const char* test_internal__byte_codec()
|
||||
{
|
||||
{ /* decode */
|
||||
const uint8_t data[] = { 0x11, 0x22, 0x33, 0x44 };
|
||||
@ -61,7 +61,7 @@ const char* test_internal__byte_codec()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void gmio_test_atof_fprintf_err(
|
||||
static void __tc__fprintf_atof_err(
|
||||
const char* func_fast_atof_str,
|
||||
const char* val_str,
|
||||
float fast_val,
|
||||
@ -84,7 +84,7 @@ static void gmio_test_atof_fprintf_err(
|
||||
gmio_float32_ulp_diff(fast_val, std_val));
|
||||
}
|
||||
|
||||
static bool gmio_test_calculation_atof(const char* val_str)
|
||||
static bool __tc__check_calculation_atof(const char* val_str)
|
||||
{
|
||||
const float std_val = (float)strtod(val_str, NULL);
|
||||
int accurate_count = 0;
|
||||
@ -94,7 +94,7 @@ static bool gmio_test_calculation_atof(const char* val_str)
|
||||
if (gmio_float32_ulp_equals(fast_val, std_val, 1))
|
||||
++accurate_count;
|
||||
else
|
||||
gmio_test_atof_fprintf_err("fast_atof", val_str, fast_val, std_val);
|
||||
__tc__fprintf_atof_err("fast_atof", val_str, fast_val, std_val);
|
||||
}
|
||||
|
||||
{ /* Test gmio_stringstream_fast_atof() */
|
||||
@ -110,7 +110,7 @@ static bool gmio_test_calculation_atof(const char* val_str)
|
||||
++accurate_count;
|
||||
}
|
||||
else {
|
||||
gmio_test_atof_fprintf_err(
|
||||
__tc__fprintf_atof_err(
|
||||
"gmio_stringstream_fast_atof", val_str, fast_val, std_val);
|
||||
}
|
||||
}
|
||||
@ -118,46 +118,46 @@ static bool gmio_test_calculation_atof(const char* val_str)
|
||||
return accurate_count == 2;
|
||||
}
|
||||
|
||||
const char* test_internal__fast_atof()
|
||||
static const char* test_internal__fast_atof()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
ok = ok && gmio_test_calculation_atof("340282346638528859811704183484516925440.000000");
|
||||
ok = ok && gmio_test_calculation_atof("3.402823466e+38F");
|
||||
ok = ok && gmio_test_calculation_atof("3402823466e+29F");
|
||||
ok = ok && gmio_test_calculation_atof("-340282346638528859811704183484516925440.000000");
|
||||
ok = ok && gmio_test_calculation_atof("-3.402823466e+38F");
|
||||
ok = ok && gmio_test_calculation_atof("-3402823466e+29F");
|
||||
ok = ok && gmio_test_calculation_atof("34028234663852885981170418348451692544.000000");
|
||||
ok = ok && gmio_test_calculation_atof("3.402823466e+37F");
|
||||
ok = ok && gmio_test_calculation_atof("3402823466e+28F");
|
||||
ok = ok && gmio_test_calculation_atof("-34028234663852885981170418348451692544.000000");
|
||||
ok = ok && gmio_test_calculation_atof("-3.402823466e+37F");
|
||||
ok = ok && gmio_test_calculation_atof("-3402823466e+28F");
|
||||
ok = ok && gmio_test_calculation_atof(".00234567");
|
||||
ok = ok && gmio_test_calculation_atof("-.00234567");
|
||||
ok = ok && gmio_test_calculation_atof("0.00234567");
|
||||
ok = ok && gmio_test_calculation_atof("-0.00234567");
|
||||
ok = ok && gmio_test_calculation_atof("1.175494351e-38F");
|
||||
ok = ok && __tc__check_calculation_atof("340282346638528859811704183484516925440.000000");
|
||||
ok = ok && __tc__check_calculation_atof("3.402823466e+38F");
|
||||
ok = ok && __tc__check_calculation_atof("3402823466e+29F");
|
||||
ok = ok && __tc__check_calculation_atof("-340282346638528859811704183484516925440.000000");
|
||||
ok = ok && __tc__check_calculation_atof("-3.402823466e+38F");
|
||||
ok = ok && __tc__check_calculation_atof("-3402823466e+29F");
|
||||
ok = ok && __tc__check_calculation_atof("34028234663852885981170418348451692544.000000");
|
||||
ok = ok && __tc__check_calculation_atof("3.402823466e+37F");
|
||||
ok = ok && __tc__check_calculation_atof("3402823466e+28F");
|
||||
ok = ok && __tc__check_calculation_atof("-34028234663852885981170418348451692544.000000");
|
||||
ok = ok && __tc__check_calculation_atof("-3.402823466e+37F");
|
||||
ok = ok && __tc__check_calculation_atof("-3402823466e+28F");
|
||||
ok = ok && __tc__check_calculation_atof(".00234567");
|
||||
ok = ok && __tc__check_calculation_atof("-.00234567");
|
||||
ok = ok && __tc__check_calculation_atof("0.00234567");
|
||||
ok = ok && __tc__check_calculation_atof("-0.00234567");
|
||||
ok = ok && __tc__check_calculation_atof("1.175494351e-38F");
|
||||
#if 0
|
||||
/* This check fails */
|
||||
ok = ok && gmio_test_calculation_atof("1175494351e-47F");
|
||||
ok = ok && __tc__check_calculation_atof("1175494351e-47F");
|
||||
#endif
|
||||
ok = ok && gmio_test_calculation_atof("1.175494351e-37F");
|
||||
ok = ok && gmio_test_calculation_atof("1.175494351e-36F");
|
||||
ok = ok && gmio_test_calculation_atof("-1.175494351e-36F");
|
||||
ok = ok && gmio_test_calculation_atof("123456.789");
|
||||
ok = ok && gmio_test_calculation_atof("-123456.789");
|
||||
ok = ok && gmio_test_calculation_atof("0000123456.789");
|
||||
ok = ok && gmio_test_calculation_atof("-0000123456.789");
|
||||
ok = ok && gmio_test_calculation_atof("-0.0690462109446526");
|
||||
ok = ok && __tc__check_calculation_atof("1.175494351e-37F");
|
||||
ok = ok && __tc__check_calculation_atof("1.175494351e-36F");
|
||||
ok = ok && __tc__check_calculation_atof("-1.175494351e-36F");
|
||||
ok = ok && __tc__check_calculation_atof("123456.789");
|
||||
ok = ok && __tc__check_calculation_atof("-123456.789");
|
||||
ok = ok && __tc__check_calculation_atof("0000123456.789");
|
||||
ok = ok && __tc__check_calculation_atof("-0000123456.789");
|
||||
ok = ok && __tc__check_calculation_atof("-0.0690462109446526");
|
||||
|
||||
UTEST_ASSERT(ok);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_internal__safe_cast()
|
||||
static const char* test_internal__safe_cast()
|
||||
{
|
||||
#if GMIO_TARGET_ARCH_BIT_SIZE > 32
|
||||
const size_t maxUInt32 = 0xFFFFFFFF;
|
||||
@ -180,7 +180,7 @@ const char* test_internal__safe_cast()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_internal__stringstream()
|
||||
static const char* test_internal__stringstream()
|
||||
{
|
||||
static const char text[] =
|
||||
"Une citation,\to je crois qu'elle est de moi :"
|
||||
@ -264,7 +264,7 @@ const char* test_internal__stringstream()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_internal__string_utils()
|
||||
static const char* test_internal__string_utils()
|
||||
{
|
||||
char c; /* for loop counter */
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
/* Disable MSVC warning "conditional expression is constant" */
|
||||
GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(4127)
|
||||
|
||||
const char* test_platform__global_h()
|
||||
static const char* test_platform__global_h()
|
||||
{
|
||||
UTEST_ASSERT(sizeof(int8_t) == 1);
|
||||
UTEST_ASSERT(sizeof(uint8_t) == 1);
|
||||
@ -46,7 +46,7 @@ const char* test_platform__global_h()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_platform__compiler()
|
||||
static const char* test_platform__compiler()
|
||||
{
|
||||
/* Check that universal zero initializer {0} works as expected
|
||||
*
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* generic_test_stl_infos(const struct stl_read_testcase* testcase)
|
||||
static const char* __tstl__test_stl_infos(
|
||||
const struct stl_read_testcase* testcase)
|
||||
{
|
||||
FILE* file = fopen(testcase->filepath, "rb");
|
||||
gmio_streamsize_t expected_size = testcase->expected_size;
|
||||
@ -68,11 +69,11 @@ const char* generic_test_stl_infos(const struct stl_read_testcase* testcase)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stl_infos()
|
||||
static const char* test_stl_infos()
|
||||
{
|
||||
const struct stl_read_testcase* testcase = stl_read_testcases_ptr();
|
||||
while (testcase != stl_read_testcases_ptr_end()) {
|
||||
const char* error = generic_test_stl_infos(testcase);
|
||||
const char* error = __tstl__test_stl_infos(testcase);
|
||||
if (error != NULL) {
|
||||
fprintf(stderr,
|
||||
"\ntest_stl_infos()\n"
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
const char* test_stl_internal__rw_common()
|
||||
static const char* test_stl_internal__rw_common()
|
||||
{
|
||||
/* gmio_check_memblock() */
|
||||
{
|
||||
|
@ -30,16 +30,17 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct stl_testcase_result
|
||||
struct __tstl__testcase_result
|
||||
{
|
||||
char solid_name[2048];
|
||||
};
|
||||
|
||||
void stl_testcase_result__begin_solid(
|
||||
static void __tstl__testcase_result__begin_solid(
|
||||
void* cookie, const struct gmio_stl_mesh_creator_infos* infos)
|
||||
{
|
||||
if (infos->format == GMIO_STL_FORMAT_ASCII) {
|
||||
struct stl_testcase_result* res = (struct stl_testcase_result*)cookie;
|
||||
struct __tstl__testcase_result* res =
|
||||
(struct __tstl__testcase_result*)cookie;
|
||||
if (res != NULL) {
|
||||
res->solid_name[0] = 0;
|
||||
if (infos->stla_solid_name != NULL)
|
||||
@ -52,14 +53,14 @@ void stl_testcase_result__begin_solid(
|
||||
}
|
||||
}
|
||||
|
||||
const char* test_stl_read()
|
||||
static const char* test_stl_read()
|
||||
{
|
||||
const struct stl_read_testcase* testcase = stl_read_testcases_ptr();
|
||||
struct gmio_stl_mesh_creator mesh_creator = {0};
|
||||
struct stl_testcase_result result = {0};
|
||||
struct __tstl__testcase_result result = {0};
|
||||
|
||||
mesh_creator.cookie = &result;
|
||||
mesh_creator.func_begin_solid = &stl_testcase_result__begin_solid;
|
||||
mesh_creator.func_begin_solid = &__tstl__testcase_result__begin_solid;
|
||||
mesh_creator.func_add_triangle = &gmio_stl_nop_add_triangle;
|
||||
|
||||
while (testcase != stl_read_testcases_ptr_end()) {
|
||||
@ -111,7 +112,7 @@ const char* test_stl_read()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stlb_read()
|
||||
static const char* test_stlb_read()
|
||||
{
|
||||
/* This file contains only a header and facet count(100) but no triangles */
|
||||
FILE* file = fopen(filepath_stlb_header_nofacets, "rb");
|
||||
@ -128,7 +129,7 @@ const char* test_stlb_read()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stlb_header_write()
|
||||
static const char* test_stlb_header_write()
|
||||
{
|
||||
const char* filepath = "temp/solid.stlb";
|
||||
struct gmio_stlb_header header = {0};
|
||||
@ -160,7 +161,7 @@ const char* test_stlb_header_write()
|
||||
}
|
||||
|
||||
/* Safely closes the two files \p f1 and \p f2 */
|
||||
static void fclose_2(FILE* f1, FILE* f2)
|
||||
static void __tstl__fclose_2(FILE* f1, FILE* f2)
|
||||
{
|
||||
if (f1 != NULL)
|
||||
fclose(f1);
|
||||
@ -168,7 +169,7 @@ static void fclose_2(FILE* f1, FILE* f2)
|
||||
fclose(f2);
|
||||
}
|
||||
|
||||
const char* test_stlb_write()
|
||||
static const char* test_stlb_write()
|
||||
{
|
||||
const char* model_fpath = filepath_stlb_grabcad_arm11;
|
||||
const char* model_fpath_out = "temp/solid.le_stlb";
|
||||
@ -209,7 +210,7 @@ const char* test_stlb_write()
|
||||
FILE* in = fopen(model_fpath, "rb");
|
||||
FILE* out = fopen(model_fpath_out, "rb");
|
||||
if (in == NULL || out == NULL) {
|
||||
fclose_2(in, out);
|
||||
__tstl__fclose_2(in, out);
|
||||
perror("test_stlb_write()");
|
||||
UTEST_FAIL("fopen() error for in/out model files");
|
||||
}
|
||||
@ -217,16 +218,16 @@ const char* test_stlb_write()
|
||||
bytes_read_in = fread(buffer_in, 1, buff_size, in);
|
||||
bytes_read_out = fread(buffer_out, 1, buff_size, out);
|
||||
if (bytes_read_in != bytes_read_out) {
|
||||
fclose_2(in, out);
|
||||
__tstl__fclose_2(in, out);
|
||||
UTEST_FAIL("Different byte count between in/out");
|
||||
}
|
||||
if (memcmp(buffer_in, buffer_out, buff_size) != 0) {
|
||||
fclose_2(in, out);
|
||||
__tstl__fclose_2(in, out);
|
||||
UTEST_FAIL("Different buffer contents between in/out");
|
||||
}
|
||||
} while (!feof(in) && !feof(out)
|
||||
&& bytes_read_in > 0 && bytes_read_out > 0);
|
||||
fclose_2(in, out);
|
||||
__tstl__fclose_2(in, out);
|
||||
}
|
||||
|
||||
/* Check output LE/BE models are equal */
|
||||
@ -249,7 +250,7 @@ const char* test_stlb_write()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stla_write()
|
||||
static const char* test_stla_write()
|
||||
{
|
||||
const char* model_filepath = filepath_stlb_grabcad_arm11;
|
||||
const char* model_filepath_out = "temp/solid.stla";
|
||||
@ -305,7 +306,7 @@ const char* test_stla_write()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* generic_test_stl_read_multi_solid(
|
||||
static const char* __tstl__test_stl_read_multi_solid(
|
||||
const char* filepath, unsigned expected_solid_count)
|
||||
{
|
||||
FILE* infile = fopen(filepath, "rb");
|
||||
@ -331,17 +332,17 @@ const char* generic_test_stl_read_multi_solid(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stl_read_multi_solid()
|
||||
static const char* test_stl_read_multi_solid()
|
||||
{
|
||||
const char* res = NULL;
|
||||
res = generic_test_stl_read_multi_solid(filepath_stla_4meshs, 4);
|
||||
res = __tstl__test_stl_read_multi_solid(filepath_stla_4meshs, 4);
|
||||
if (res != NULL)
|
||||
return res;
|
||||
res = generic_test_stl_read_multi_solid(filepath_stlb_4meshs, 4);
|
||||
res = __tstl__test_stl_read_multi_solid(filepath_stlb_4meshs, 4);
|
||||
return res;
|
||||
}
|
||||
|
||||
void generate_stlb_tests_models()
|
||||
static void generate_stlb_tests_models()
|
||||
{
|
||||
{
|
||||
FILE* outfile = fopen(filepath_stlb_empty, "wb");
|
||||
|
@ -25,7 +25,7 @@
|
||||
/* Disable MSVC warning "conditional expression is constant" */
|
||||
GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(4127)
|
||||
|
||||
const char* test_stl_coords_packing()
|
||||
static const char* test_stl_coords_packing()
|
||||
{
|
||||
UTEST_COMPARE_UINT(0, offsetof(struct gmio_vec3f, x));
|
||||
UTEST_COMPARE_UINT(4, offsetof(struct gmio_vec3f, y));
|
||||
@ -34,7 +34,7 @@ const char* test_stl_coords_packing()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stl_triangle_packing()
|
||||
static const char* test_stl_triangle_packing()
|
||||
{
|
||||
UTEST_COMPARE_UINT(0, offsetof(struct gmio_stl_triangle, n));
|
||||
UTEST_COMPARE_UINT(GMIO_STL_COORDS_RAWSIZE, offsetof(struct gmio_stl_triangle, v1));
|
||||
@ -45,7 +45,7 @@ const char* test_stl_triangle_packing()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stl_triangle_compute_normal()
|
||||
static const char* test_stl_triangle_compute_normal()
|
||||
{
|
||||
const unsigned udiff = 5;
|
||||
{ /* Doesn't fail on invalid facet */
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
const char* test_stlb_header_str()
|
||||
static const char* test_stlb_header_str()
|
||||
{
|
||||
const struct gmio_stlb_header null = {0};
|
||||
|
||||
@ -54,7 +54,7 @@ const char* test_stlb_header_str()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_stlb_header_to_printable_str()
|
||||
static const char* test_stlb_header_to_printable_str()
|
||||
{
|
||||
{
|
||||
const struct gmio_stlb_header null = {0};
|
||||
|
Loading…
Reference in New Issue
Block a user