xref: /aosp_15_r20/external/nanopb-c/tests/multiple_files/test_multiple_files.c (revision c8d645cafcee3f91213d30caa0fe303887010b9b)
1 /*
2  * Tests if this still compiles when multiple .proto files are involved.
3  */
4 
5 #include <stdio.h>
6 #include <pb_encode.h>
7 #include "unittests.h"
8 #include "multifile2.pb.h"
9 #include "subdir/multifile2.pb.h"
10 
main()11 int main()
12 {
13     int status = 0;
14 
15     /* Test that included file options are properly loaded */
16     TEST(OneofMessage_size == 27);
17 
18     /* Check that enum signedness is detected properly */
19     TEST(PB_LTYPE(Enums_fields[0].type) == PB_LTYPE_VARINT);
20     TEST(PB_LTYPE(Enums_fields[1].type) == PB_LTYPE_UVARINT);
21 
22     /* Test that subdir file is correctly included */
23     {
24         subdir_SubdirMessage foo = subdir_SubdirMessage_init_default;
25         TEST(foo.foo == 15);
26         TEST(subdir_OneofMessage_size >= 27); /* Note: not perfectly accurate due to issue 172 */
27         TEST(subdir_OneofMessage_size <= 30);
28     }
29 
30     return status;
31 }
32