2015-03-03 00:38:33 +08:00
|
|
|
/****************************************************************************
|
2015-05-28 15:40:24 +08:00
|
|
|
** gmio
|
2016-06-24 18:03:07 +08:00
|
|
|
** Copyright Fougue (24 Jun. 2016)
|
2015-07-13 17:42:03 +08:00
|
|
|
** contact@fougue.pro
|
2015-03-03 00:38:33 +08:00
|
|
|
**
|
|
|
|
** 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
|
|
|
****************************************************************************/
|
|
|
|
|
2015-09-14 17:20:12 +08:00
|
|
|
#include "utest_assert.h"
|
2014-02-11 18:13:15 +08:00
|
|
|
|
2014-03-28 23:33:35 +08:00
|
|
|
#include "../src/gmio_core/global.h"
|
2016-01-29 19:47:01 +08:00
|
|
|
#include "../src/gmio_core/stream.h"
|
2014-02-11 18:13:15 +08:00
|
|
|
|
|
|
|
#include <stddef.h>
|
2015-04-10 00:19:39 +08:00
|
|
|
#include <string.h>
|
2014-02-11 18:13:15 +08:00
|
|
|
|
2015-11-19 23:16:23 +08:00
|
|
|
/* Disable MSVC warning "conditional expression is constant" */
|
|
|
|
GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(4127)
|
2015-03-03 23:27:02 +08:00
|
|
|
|
2016-06-16 16:29:27 +08:00
|
|
|
static const char* test_platform__global_h()
|
2014-02-11 18:13:15 +08:00
|
|
|
{
|
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);
|
|
|
|
|
2015-11-06 19:40:57 +08:00
|
|
|
#ifdef GMIO_HAVE_INT64_TYPE
|
|
|
|
UTEST_ASSERT(sizeof(int64_t) == 8);
|
|
|
|
UTEST_ASSERT(sizeof(uint64_t) == 8);
|
|
|
|
#endif
|
|
|
|
|
2016-01-26 23:00:36 +08:00
|
|
|
UTEST_ASSERT(sizeof(float) == 4);
|
|
|
|
UTEST_ASSERT(sizeof(double) == 8);
|
2014-02-11 18:13:15 +08:00
|
|
|
|
2015-03-03 17:35:36 +08:00
|
|
|
return NULL;
|
2014-02-11 18:13:15 +08:00
|
|
|
}
|
|
|
|
|
2016-06-16 16:29:27 +08:00
|
|
|
static const char* test_platform__compiler()
|
2015-04-10 00:19:39 +08:00
|
|
|
{
|
2015-12-04 19:48:00 +08:00
|
|
|
/* Check that universal zero initializer {0} works as expected
|
2015-09-23 00:17:17 +08:00
|
|
|
*
|
|
|
|
* See http://www.ex-parrot.com/~chris/random/initialise.html
|
2015-09-08 23:58:31 +08:00
|
|
|
*
|
|
|
|
* Depending on your version, GCC can incorrectly reports the warning
|
|
|
|
* "missing braces around initializer [-Wmissing-braces]"
|
|
|
|
* See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
|
|
|
|
*/
|
2015-06-10 21:06:20 +08:00
|
|
|
{
|
2016-01-29 19:47:01 +08:00
|
|
|
const struct gmio_stream null_bracket0 = {0};
|
|
|
|
struct gmio_stream null_memset0;
|
2015-06-10 21:06:20 +08:00
|
|
|
|
2016-01-29 19:47:01 +08:00
|
|
|
memset(&null_memset0, 0, sizeof(struct gmio_stream));
|
2015-06-10 21:06:20 +08:00
|
|
|
|
|
|
|
UTEST_ASSERT(memcmp(
|
2016-01-29 19:47:01 +08:00
|
|
|
&null_bracket0,
|
|
|
|
&null_memset0,
|
|
|
|
sizeof(struct gmio_stream))
|
2015-06-10 21:06:20 +08:00
|
|
|
== 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check sizeof() operator with fixed-size arrays */
|
|
|
|
{
|
|
|
|
uint8_t buff[4 * 1024]; /* 4KB */
|
|
|
|
UTEST_ASSERT(sizeof(buff) == 4 * 1024);
|
|
|
|
}
|
2015-04-10 00:19:39 +08:00
|
|
|
|
2015-05-28 15:40:24 +08:00
|
|
|
/* gmio doesn't support platforms where NULL != 0 */
|
2015-04-10 00:19:39 +08:00
|
|
|
UTEST_ASSERT(NULL == 0);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-11-19 23:16:23 +08:00
|
|
|
GMIO_PRAGMA_MSVC_WARNING_POP()
|