summaryrefslogtreecommitdiffstats
path: root/Utilities/KWIML/test/test_abi_endian.h
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/KWIML/test/test_abi_endian.h')
-rw-r--r--Utilities/KWIML/test/test_abi_endian.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/Utilities/KWIML/test/test_abi_endian.h b/Utilities/KWIML/test/test_abi_endian.h
new file mode 100644
index 0000000..334b018
--- /dev/null
+++ b/Utilities/KWIML/test/test_abi_endian.h
@@ -0,0 +1,41 @@
+/*
+ Copyright Kitware, Inc.
+ Distributed under the OSI-approved BSD 3-Clause License.
+ See accompanying file Copyright.txt for details.
+*/
+#include <stdio.h>
+
+#ifdef __cplusplus
+# define LANG "C++ "
+#else
+# define LANG "C "
+#endif
+
+static int test_abi_endian(void)
+{
+ int result = 1;
+ {
+#if defined(KWIML_ABI_ENDIAN_ID)
+ int expect;
+ union { short s; unsigned char c[sizeof(short)]; } x;
+ x.s = 1;
+ expect = (x.c[0] == 1 ?
+ KWIML_ABI_ENDIAN_ID_LITTLE : KWIML_ABI_ENDIAN_ID_BIG);
+ printf(LANG "KWIML_ABI_ENDIAN_ID: expected [%d], got [%d]",
+ expect, KWIML_ABI_ENDIAN_ID);
+ if(KWIML_ABI_ENDIAN_ID == expect)
+ {
+ printf(", PASSED\n");
+ }
+ else
+ {
+ printf(", FAILED\n");
+ result = 0;
+ }
+#else
+ printf(LANG "KWIML_ABI_ENDIAN_ID: unknown, FAILED\n");
+ result = 0;
+#endif
+ }
+ return result;
+}