Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlassert / repo / tests / nlassert-static-test.c
1 /*
2  *
3  *    Copyright (c) 2012-2016 Nest Labs, Inc.
4  *    All rights reserved.
5  *
6  *    This document is the property of Nest. It is considered
7  *    confidential and proprietary information.
8  *
9  *    This document may not be reproduced or transmitted in any form,
10  *    in whole or in part, without the express written permission of
11  *    Nest.
12  *
13  */
14
15 /**
16  *    @file
17  *      This file implements a unit test suite for the Nest Labs
18  *      compile-time assertion library.
19  *
20  */
21
22 #include <stdint.h>
23
24 #include "nlassert-test-config.h"
25
26 #define NL_ASSERT_PRODUCTION                         (NL_ASSERT_TEST_WANT_PRODUCTION)
27
28 #include <nlassert.h>
29
30 #include <nlunit-test.h>
31
32 #if NL_ASSERT_TEST_WANT_STATIC_SUCCESS
33 #define _TEST_STATIC_OP ==
34 #else
35 #define _TEST_STATIC_OP !=
36 #endif /* NL_ASSERT_TEST_WANT_STATIC_SUCCESS */
37
38 /**
39  *  Test static, compile-time assertions outside of function bodies.
40  */
41 uint32_t test;
42
43 nlSTATIC_ASSERT(sizeof(test) _TEST_STATIC_OP 4);
44
45 nlSTATIC_ASSERT_PRINT(sizeof(test) _TEST_STATIC_OP 4, "nlASSERT_PRINT_STATIC Failed");
46
47 /**
48  *  Test static, compile-time assertions within a function body.
49  */
50 static void TestStatic(nlTestSuite *inSuite, void *inContext)
51 {
52     nlSTATIC_ASSERT(sizeof(test) _TEST_STATIC_OP 4);
53
54     nlSTATIC_ASSERT_PRINT(sizeof(test) _TEST_STATIC_OP 4, "nlASSERT_PRINT_STATIC Failed");
55 }
56
57 static const nlTest sTests[] = {
58     NL_TEST_DEF("static",       TestStatic),
59     NL_TEST_SENTINEL()
60 };
61
62 int main(void)
63 {
64     nlTestSuite theSuite = {
65         "nlassert-static",
66         &sTests[0],
67         NULL,
68         NULL
69     };
70
71     nlTestSetOutputStyle(OUTPUT_CSV);
72
73     nlTestRunner(&theSuite, NULL);
74
75     return nlTestRunnerStats(&theSuite);
76 }