1 #include <stdio.h>
2 #include "message.pb.h"
3 #include "unittests.h"
4 
main()5 extern "C" int main() {
6   using namespace nanopb;
7 
8 #if __cplusplus >= 201103L
9   static_assert(MessageDescriptor<MyEmptyMessage>::fields_array_length == 0,
10                 "Unexpected field length");
11   static_assert(MessageDescriptor<MyNonEmptyMessage>::fields_array_length == 1,
12                 "Unexpected field length");
13 #endif // C++11 & newer
14 
15   int status = 0;
16 
17   TEST(MessageDescriptor<MyEmptyMessage>::fields_array_length ==
18        MyEmptyMessage_msg.field_count);
19   TEST(MessageDescriptor<MyNonEmptyMessage>::fields_array_length ==
20        MyNonEmptyMessage_msg.field_count);
21 
22   TEST(MessageDescriptor<MyEmptyMessage>::fields() == MyEmptyMessage_fields);
23   TEST(MessageDescriptor<MyNonEmptyMessage>::fields() ==
24        MyNonEmptyMessage_fields);
25 
26   if (status != 0) fprintf(stdout, "\n\nSome tests FAILED!\n");
27 
28   return status;
29 }
30