Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-macro-utils-c/tests/mu_define_enum_2_test.c

raw
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 #include <string.h>
5 #include "test_helper.h"
6
7 #include "azure_macro_utils/macro_utils.h"
8
9 #include "mu_define_enum_2_test.h"
10
11 // This lists the values in the enum
12 #define TEST5_ENUM_VALUES \
13 test5_a, 2, \
14 test5_b, 42
15
16 // This will define an enum that has an INVALID value as first enum value and then it has the enum values
17 // mentioned in TEST5_ENUM_VALUES
18 MU_DEFINE_ENUM_2(TEST5_ENUM, TEST5_ENUM_VALUES);
19
20 MU_DEFINE_ENUM_STRINGS_2(TEST5_ENUM, TEST5_ENUM_VALUES);
21
22 int run_mu_define_enum_2_tests(void)
23 {
24 int result = 0;
25
26 TEST5_ENUM someUnusedVariable; /*but wants to see that the type "TEST5_ENUM" is a real type*/
27 (void)someUnusedVariable;
28
29 POOR_MANS_ASSERT(TEST5_ENUM_INVALID == (int)0xDDDDDDDD);
30 POOR_MANS_ASSERT(test5_a == 2);
31 POOR_MANS_ASSERT(test5_b == 42);
32
33 const char* TEST5_test5_a = MU_ENUM_TO_STRING_2(TEST5_ENUM, 2);
34 POOR_MANS_ASSERT(TEST5_test5_a != NULL);
35 POOR_MANS_ASSERT(strcmp("test5_a", TEST5_test5_a) == 0);
36
37 const char* TEST5_test5_b = MU_ENUM_TO_STRING_2(TEST5_ENUM, 42);
38 POOR_MANS_ASSERT(TEST5_test5_b != NULL);
39 POOR_MANS_ASSERT(strcmp("test5_b", TEST5_test5_b) == 0);
40
41 POOR_MANS_ASSERT(MU_ENUM_2_VALUE_COUNT(TEST5_ENUM_VALUES) == 3);
42
43 return result;
44 }