Publishing nanopb-0.3.6
[apps/agl-service-can-low-level.git] / tests / alltypes / encode_alltypes.c
index 88fc10f..16f4b29 100644 (file)
@@ -13,7 +13,7 @@ int main(int argc, char **argv)
     int mode = (argc > 1) ? atoi(argv[1]) : 0;
     
     /* Initialize the structure with constants */
-    AllTypes alltypes = {0};
+    AllTypes alltypes = AllTypes_init_zero;
     
     alltypes.req_int32         = -1001;
     alltypes.req_int64         = -1002;
@@ -67,6 +67,17 @@ int main(int argc, char **argv)
     alltypes.rep_enum_count = 5; alltypes.rep_enum[4] = MyEnum_Truth;
     alltypes.rep_emptymsg_count = 5;
     
+    alltypes.req_limits.int32_min  = INT32_MIN;
+    alltypes.req_limits.int32_max  = INT32_MAX;
+    alltypes.req_limits.uint32_min = 0;
+    alltypes.req_limits.uint32_max = UINT32_MAX;
+    alltypes.req_limits.int64_min  = INT64_MIN;
+    alltypes.req_limits.int64_max  = INT64_MAX;
+    alltypes.req_limits.uint64_min = 0;
+    alltypes.req_limits.uint64_max = UINT64_MAX;
+    alltypes.req_limits.enum_min   = HugeEnum_Negative;
+    alltypes.req_limits.enum_max   = HugeEnum_Positive;
+    
     if (mode != 0)
     {
         /* Fill in values for optional fields */
@@ -110,12 +121,16 @@ int main(int argc, char **argv)
         alltypes.has_opt_enum = true;
         alltypes.opt_enum = MyEnum_Truth;
         alltypes.has_opt_emptymsg = true;
+
+        alltypes.which_oneof = AllTypes_oneof_msg1_tag;
+        strcpy(alltypes.oneof.oneof_msg1.substuff1, "4059");
+        alltypes.oneof.oneof_msg1.substuff2 = 4059;
     }
     
     alltypes.end = 1099;
     
     {
-        uint8_t buffer[1024];
+        uint8_t buffer[AllTypes_size];
         pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
         
         /* Now encode it and check if we succeeded. */