Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_status / status_test_c.c
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include <string.h>
16
17 #include "pw_status/status.h"
18
19 pw_Status PassStatusFromC(pw_Status status) { return status; }
20
21 pw_Status PassStatusFromCpp(pw_Status status);
22
23 #define CHECK_STATUS_FROM_CPP(status) \
24   (PW_STATUS_##status != PassStatusFromCpp(PW_STATUS_##status))
25
26 int TestStatusFromC() {
27   int errors = 0;
28
29   errors += CHECK_STATUS_FROM_CPP(OK);
30   errors += CHECK_STATUS_FROM_CPP(CANCELLED);
31   errors += CHECK_STATUS_FROM_CPP(UNKNOWN);
32   errors += CHECK_STATUS_FROM_CPP(INVALID_ARGUMENT);
33   errors += CHECK_STATUS_FROM_CPP(DEADLINE_EXCEEDED);
34   errors += CHECK_STATUS_FROM_CPP(NOT_FOUND);
35   errors += CHECK_STATUS_FROM_CPP(ALREADY_EXISTS);
36   errors += CHECK_STATUS_FROM_CPP(PERMISSION_DENIED);
37   errors += CHECK_STATUS_FROM_CPP(UNAUTHENTICATED);
38   errors += CHECK_STATUS_FROM_CPP(RESOURCE_EXHAUSTED);
39   errors += CHECK_STATUS_FROM_CPP(FAILED_PRECONDITION);
40   errors += CHECK_STATUS_FROM_CPP(ABORTED);
41   errors += CHECK_STATUS_FROM_CPP(OUT_OF_RANGE);
42   errors += CHECK_STATUS_FROM_CPP(UNIMPLEMENTED);
43   errors += CHECK_STATUS_FROM_CPP(INTERNAL);
44   errors += CHECK_STATUS_FROM_CPP(UNAVAILABLE);
45   errors += CHECK_STATUS_FROM_CPP(DATA_LOSS);
46
47   return errors;
48 }
49
50 #undef CHECK_STATUS_FROM_CPP
51
52 #define CHECK_STATUS_STRING(status) \
53   (strcmp(#status, pw_StatusString(PW_STATUS_##status)) != 0)
54
55 int TestStatusStringsFromC() {
56   int errors = 0;
57
58   errors += CHECK_STATUS_STRING(OK);
59   errors += CHECK_STATUS_STRING(CANCELLED);
60   errors += CHECK_STATUS_STRING(DEADLINE_EXCEEDED);
61   errors += CHECK_STATUS_STRING(NOT_FOUND);
62   errors += CHECK_STATUS_STRING(ALREADY_EXISTS);
63   errors += CHECK_STATUS_STRING(PERMISSION_DENIED);
64   errors += CHECK_STATUS_STRING(UNAUTHENTICATED);
65   errors += CHECK_STATUS_STRING(RESOURCE_EXHAUSTED);
66   errors += CHECK_STATUS_STRING(FAILED_PRECONDITION);
67   errors += CHECK_STATUS_STRING(ABORTED);
68   errors += CHECK_STATUS_STRING(OUT_OF_RANGE);
69   errors += CHECK_STATUS_STRING(UNIMPLEMENTED);
70   errors += CHECK_STATUS_STRING(INTERNAL);
71   errors += CHECK_STATUS_STRING(UNAVAILABLE);
72   errors += CHECK_STATUS_STRING(DATA_LOSS);
73
74   return errors;
75 }
76
77 #undef CHECK_STATUS_STRING