Welcome to mirror list, hosted at ThFree Co, Russian Federation.

message_descriptor.cc « cxx_descriptor « tests - github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cbaae7e3c8bb1b6f91233c755669a1b5a70a5990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include "message.pb.h"
#include "unittests.h"

extern "C" int main() {
  using namespace nanopb;

#if __cplusplus >= 201103L
  static_assert(MessageDescriptor<MyEmptyMessage>::fields_array_length == 0,
                "Unexpected field length");
  static_assert(MessageDescriptor<MyNonEmptyMessage>::fields_array_length == 1,
                "Unexpected field length");
#endif // C++11 & newer

  int status = 0;

  TEST(MessageDescriptor<MyEmptyMessage>::fields_array_length ==
       MyEmptyMessage_msg.field_count);
  TEST(MessageDescriptor<MyNonEmptyMessage>::fields_array_length ==
       MyNonEmptyMessage_msg.field_count);

  TEST(MessageDescriptor<MyNonEmptyMessage>::max_size ==
       MyNonEmptyMessage_size);

  TEST(MessageDescriptor<MyEmptyMessage>::fields() == MyEmptyMessage_fields);
  TEST(MessageDescriptor<MyNonEmptyMessage>::fields() ==
       MyNonEmptyMessage_fields);

  TEST(MessageDescriptor<MyMessageWithMsgid>::has_msgid() == true);
  TEST(MessageDescriptor<MyMessageWithMsgid>::msgid() == 42);

  TEST(MessageDescriptor<MyMessageWithoutMsgid>::has_msgid() == false);


  if (status != 0) fprintf(stdout, "\n\nSome tests FAILED!\n");

  return status;
}