Add fixed length bytes to alltypes test case (issue #244)
[apps/agl-service-can-low-level.git] / tests / alltypes_pointer / encode_alltypes_pointer.c
index dabee73..a39af6f 100644 (file)
@@ -27,11 +27,12 @@ int main(int argc, char **argv)
     int64_t     req_sfixed64      = -1012;
     double      req_double        = 1013.0;
     char*       req_string        = "1014";
-    pb_bytes_ptr_t req_bytes      = {4, (uint8_t*)"1015"};
+    PB_BYTES_ARRAY_T(4) req_bytes = {4, {'1', '0', '1', '5'}};
     static int32_t req_substuff   = 1016;
     SubMessage  req_submsg        = {"1016", &req_substuff};
     MyEnum      req_enum          = MyEnum_Truth;
     EmptyMessage req_emptymsg     = {0};
+    pb_byte_t   req_fbytes[4]     = {'1', '0', '1', '9'};
     
     int32_t     end               = 1099;
 
@@ -50,7 +51,8 @@ int main(int argc, char **argv)
     int64_t     rep_sfixed64[5]   = {0, 0, 0, 0, -2012};
     double      rep_double[5]     = {0, 0, 0, 0, 2013.0f};
     char*       rep_string[5]     = {"", "", "", "", "2014"};
-    pb_bytes_ptr_t rep_bytes[5]   = {{0,0}, {0,0}, {0,0}, {0,0}, {4, (uint8_t*)"2015"}};
+    static PB_BYTES_ARRAY_T(4) rep_bytes_4 = {4, {'2', '0', '1', '5'}};
+    pb_bytes_array_t *rep_bytes[5]= {NULL, NULL, NULL, NULL, (pb_bytes_array_t*)&rep_bytes_4};
     static int32_t rep_sub2zero   = 0;
     static int32_t rep_substuff2  = 2016;
     static uint32_t rep_substuff3 = 2016;
@@ -61,6 +63,7 @@ int main(int argc, char **argv)
                                      {"2016", &rep_substuff2, &rep_substuff3}};
     MyEnum      rep_enum[5]       = {0, 0, 0, 0, MyEnum_Truth};
     EmptyMessage rep_emptymsg[5]  = {{0}, {0}, {0}, {0}, {0}};
+    pb_byte_t   rep_fbytes[5][4]  = {{0}, {0}, {0}, {0}, {'2', '0', '1', '9'}};
 
     /* Values for optional fields */
     int32_t     opt_int32         = 3041;
@@ -77,11 +80,32 @@ int main(int argc, char **argv)
     int64_t     opt_sfixed64      = 3052;
     double      opt_double        = 3053.0;
     char*       opt_string        = "3054";
-    pb_bytes_ptr_t opt_bytes      = {4, (uint8_t*)"3055"};
+    PB_BYTES_ARRAY_T(4) opt_bytes = {4, {'3', '0', '5', '5'}};
     static int32_t opt_substuff   = 3056;
     SubMessage  opt_submsg        = {"3056", &opt_substuff};
     MyEnum      opt_enum          = MyEnum_Truth;
     EmptyMessage opt_emptymsg     = {0};
+    pb_byte_t   opt_fbytes[4]     = {'3', '0', '5', '9'};
+
+    static int32_t oneof_substuff = 4059;
+    SubMessage  oneof_msg1        = {"4059", &oneof_substuff};
+
+    /* Values for the Limits message. */
+    static int32_t  int32_min  = INT32_MIN;
+    static int32_t  int32_max  = INT32_MAX;
+    static uint32_t uint32_min = 0;
+    static uint32_t uint32_max = UINT32_MAX;
+    static int64_t  int64_min  = INT64_MIN;
+    static int64_t  int64_max  = INT64_MAX;
+    static uint64_t uint64_min = 0;
+    static uint64_t uint64_max = UINT64_MAX;
+    static HugeEnum enum_min   = HugeEnum_Negative;
+    static HugeEnum enum_max   = HugeEnum_Positive;
+    Limits req_limits = {&int32_min,    &int32_max,
+                         &uint32_min,   &uint32_max,
+                         &int64_min,    &int64_max,
+                         &uint64_min,   &uint64_max,
+                         &enum_min,     &enum_max};
 
     /* Initialize the message struct with pointers to the fields. */
     AllTypes alltypes = {0};
@@ -100,10 +124,12 @@ int main(int argc, char **argv)
     alltypes.req_sfixed64      = &req_sfixed64;
     alltypes.req_double        = &req_double;
     alltypes.req_string        = req_string;
-    alltypes.req_bytes         = &req_bytes;
+    alltypes.req_bytes         = (pb_bytes_array_t*)&req_bytes;
     alltypes.req_submsg        = &req_submsg;
     alltypes.req_enum          = &req_enum;
     alltypes.req_emptymsg      = &req_emptymsg;
+    alltypes.req_fbytes        = &req_fbytes;
+    alltypes.req_limits        = &req_limits;
     
     alltypes.rep_int32_count    = 5; alltypes.rep_int32     = rep_int32;
     alltypes.rep_int64_count    = 5; alltypes.rep_int64     = rep_int64;
@@ -123,6 +149,7 @@ int main(int argc, char **argv)
     alltypes.rep_submsg_count   = 5; alltypes.rep_submsg    = rep_submsg;
     alltypes.rep_enum_count     = 5; alltypes.rep_enum      = rep_enum;
     alltypes.rep_emptymsg_count = 5; alltypes.rep_emptymsg  = rep_emptymsg;
+    alltypes.rep_fbytes_count   = 5; alltypes.rep_fbytes    = rep_fbytes;
     
     if (mode != 0)
     {
@@ -141,10 +168,14 @@ int main(int argc, char **argv)
         alltypes.opt_sfixed64      = &opt_sfixed64;
         alltypes.opt_double        = &opt_double;
         alltypes.opt_string        = opt_string;
-        alltypes.opt_bytes         = &opt_bytes;
+        alltypes.opt_bytes         = (pb_bytes_array_t*)&opt_bytes;
         alltypes.opt_submsg        = &opt_submsg;
         alltypes.opt_enum          = &opt_enum;
         alltypes.opt_emptymsg      = &opt_emptymsg;
+        alltypes.opt_fbytes        = &opt_fbytes;
+
+        alltypes.which_oneof = AllTypes_oneof_msg1_tag;
+        alltypes.oneof.oneof_msg1 = &oneof_msg1;
     }
     
     alltypes.end = &end;