| 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_test.h" |
| 10 |
|
| 11 |
// This lists the values in the enum |
| 12 |
#define TEST4_ENUM_VALUES \ |
| 13 |
test4_a, \ |
| 14 |
test4_b |
| 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 TEST4_ENUM_VALUES |
| 18 |
MU_DEFINE_ENUM(TEST4_ENUM, TEST4_ENUM_VALUES); |
| 19 |
MU_DEFINE_ENUM_STRINGS(TEST4_ENUM, TEST4_ENUM_VALUES); |
| 20 |
|
| 21 |
int run_mu_define_enum_tests(void) |
| 22 |
{ |
| 23 |
int result = 0; |
| 24 |
|
| 25 |
TEST4_ENUM someUnusedVariable; /*but wants to see that the type "TEST4_ENUM" is a real type*/ |
| 26 |
(void)someUnusedVariable; |
| 27 |
|
| 28 |
POOR_MANS_ASSERT(TEST4_ENUM_INVALID == 0); |
| 29 |
POOR_MANS_ASSERT(test4_a == 1); |
| 30 |
|
| 31 |
const char* TEST4_test4_a = MU_ENUM_TO_STRING(TEST4_ENUM, 1); |
| 32 |
POOR_MANS_ASSERT(TEST4_test4_a != NULL); |
| 33 |
POOR_MANS_ASSERT(strcmp("test4_a", TEST4_test4_a) == 0); |
| 34 |
|
| 35 |
POOR_MANS_ASSERT(MU_ENUM_VALUE_COUNT(TEST4_ENUM_VALUES) == 3); |
| 36 |
|
| 37 |
return result; |
| 38 |
} |