MOS Source Code
Loading...
Searching...
No Matches
message_descriptor.cc
Go to the documentation of this file.
1#include <stdio.h>
2#include "message.pb.h"
3#include "unittests.h"
4
5extern "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<MyNonEmptyMessage>::size ==
23 MyNonEmptyMessage_size);
24 TEST(MessageDescriptor<MyMessageWithSizeBoundRepeatedFields>::size ==
25 MyMessageWithSizeBoundRepeatedFields_size);
26
27 TEST(MessageDescriptor<MyEmptyMessage>::fields() == MyEmptyMessage_fields);
28 TEST(MessageDescriptor<MyNonEmptyMessage>::fields() ==
29 MyNonEmptyMessage_fields);
30
31 TEST(MessageDescriptor<MyMessageWithMsgid>::has_msgid() == true);
32 TEST(MessageDescriptor<MyMessageWithMsgid>::msgid() == 42);
33
34 TEST(MessageDescriptor<MyMessageWithoutMsgid>::has_msgid() == false);
35
36
37 if (status != 0) fprintf(stdout, "\n\nSome tests FAILED!\n");
38
39 return status;
40}
#define stdout
Definition mos_stdio.h:31
int main()
#define TEST(x)
Definition test.h:3