gmio/tests/test_platform.c

104 lines
3.2 KiB
C
Raw Normal View History

2015-03-03 00:38:33 +08:00
/****************************************************************************
**
** GeomIO Library
2015-05-01 00:19:45 +08:00
** Copyright Fougue (2 Mar. 2015)
2015-03-03 00:38:33 +08:00
** contact@fougsys.fr
**
** This software is a reusable library whose purpose is to provide complete
** I/O support for various CAD file formats (eg. STL)
**
** This software is governed by the CeCILL-B license under French law and
** abiding by the rules of distribution of free software. You can use,
** modify and/ or redistribute the software under the terms of the CeCILL-B
** license as circulated by CEA, CNRS and INRIA at the following URL
2015-03-30 15:05:25 +08:00
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
2015-03-03 00:38:33 +08:00
**
****************************************************************************/
#include "utest_lib.h"
#include "../src/gmio_core/global.h"
2015-04-10 00:19:39 +08:00
#include "../src/gmio_core/transfer.h"
#include "../src/gmio_stl/stl_triangle.h"
#include <stddef.h>
2015-04-10 00:19:39 +08:00
#include <string.h>
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable : 4127) /* "conditional expression is constant" */
#endif
const char* test_platform__alignment()
{
2015-03-03 17:35:36 +08:00
UTEST_ASSERT(offsetof(gmio_stl_coords_t, x) == 0);
UTEST_ASSERT(offsetof(gmio_stl_coords_t, y) == 4);
UTEST_ASSERT(offsetof(gmio_stl_coords_t, z) == 8);
UTEST_ASSERT(sizeof(gmio_stl_coords_t) == GMIO_STL_COORDS_RAWSIZE);
2015-03-03 17:35:36 +08:00
UTEST_ASSERT(offsetof(gmio_stl_triangle_t, normal) == 0);
UTEST_ASSERT(offsetof(gmio_stl_triangle_t, v1) == GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(offsetof(gmio_stl_triangle_t, v2) == 2*GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(offsetof(gmio_stl_triangle_t, v3) == 3*GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(offsetof(gmio_stl_triangle_t, attribute_byte_count) == 4*GMIO_STL_COORDS_RAWSIZE);
UTEST_ASSERT(sizeof(gmio_stl_triangle_t) >= GMIO_STLB_TRIANGLE_RAWSIZE);
return NULL;
}
const char* test_platform__global_h()
{
2015-03-03 17:35:36 +08:00
UTEST_ASSERT(sizeof(int8_t) == 1);
UTEST_ASSERT(sizeof(uint8_t) == 1);
UTEST_ASSERT(sizeof(int16_t) == 2);
UTEST_ASSERT(sizeof(uint16_t) == 2);
UTEST_ASSERT(sizeof(int32_t) == 4);
UTEST_ASSERT(sizeof(uint32_t) == 4);
UTEST_ASSERT(sizeof(gmio_float32_t) == 4);
UTEST_ASSERT(sizeof(gmio_float64_t) == 8);
2015-03-03 17:35:36 +08:00
return NULL;
}
2015-04-10 00:19:39 +08:00
const char* test_platform__compiler()
{
/* Check that initialization with { 0 } works as expected */
const gmio_transfer_t trsf_null_bracket0 = { 0 };
gmio_transfer_t trsf_null_memset0;
memset(&trsf_null_memset0, 0, sizeof(gmio_transfer_t));
UTEST_ASSERT(memcmp(
&trsf_null_bracket0,
&trsf_null_memset0,
sizeof(gmio_transfer_t))
== 0);
UTEST_ASSERT(sizeof(gmio_transfer_t) >= (sizeof(gmio_stream_t)
+ sizeof(gmio_buffer_t)
+ sizeof(gmio_task_iface_t)));
/* GeomIO doesn't support platforms where NULL != 0 */
UTEST_ASSERT(NULL == 0);
return NULL;
}
#ifdef _MSC_VER
# pragma warning(pop)
#endif
const char* all_tests()
{
2015-03-03 17:35:36 +08:00
UTEST_SUITE_START();
UTEST_RUN(test_platform__alignment);
UTEST_RUN(test_platform__global_h);
2015-04-10 00:19:39 +08:00
UTEST_RUN(test_platform__compiler);
2015-03-03 17:35:36 +08:00
return NULL;
}
UTEST_MAIN(all_tests)