| 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_local_enum_test.h" |
| 10 |
|
| 11 |
// This lists the values in the enum |
| 12 |
#define TEST42_LOCAL_ENUM_VALUES \ |
| 13 |
test42_a, \ |
| 14 |
test42_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 TEST42_ENUM_VALUES |
| 18 |
// This also generates the strings for it ... |
| 19 |
MU_DEFINE_LOCAL_ENUM(TEST42_LOCAL_ENUM, TEST42_LOCAL_ENUM_VALUES); |
| 20 |
|
| 21 |
int run_mu_define_local_enum_tests(void) |
| 22 |
{ |
| 23 |
int result = 0; |
| 24 |
|
| 25 |
TEST42_LOCAL_ENUM someUnusedVariable; /*but wants to see that the type "TEST42_ENUM" is a real type*/ |
| 26 |
(void)someUnusedVariable; |
| 27 |
|
| 28 |
POOR_MANS_ASSERT(TEST42_LOCAL_ENUM_INVALID == 0); |
| 29 |
POOR_MANS_ASSERT(test42_a == 1); |
| 30 |
|
| 31 |
const char* TEST42_LOCAL_test42_a = MU_ENUM_TO_STRING(TEST42_LOCAL_ENUM, 1); |
| 32 |
POOR_MANS_ASSERT(TEST42_LOCAL_test42_a != NULL); |
| 33 |
POOR_MANS_ASSERT(strcmp("test42_a", TEST42_LOCAL_test42_a) == 0); |
| 34 |
|
| 35 |
return result; |
| 36 |
} |