Home | History | Annotate | Download | only in protobuf
      1 // Protocol Buffers - Google's data interchange format
      2 // Copyright 2008 Google Inc.  All rights reserved.
      3 // http://code.google.com/p/protobuf/
      4 //
      5 // Redistribution and use in source and binary forms, with or without
      6 // modification, are permitted provided that the following conditions are
      7 // met:
      8 //
      9 //     * Redistributions of source code must retain the above copyright
     10 // notice, this list of conditions and the following disclaimer.
     11 //     * Redistributions in binary form must reproduce the above
     12 // copyright notice, this list of conditions and the following disclaimer
     13 // in the documentation and/or other materials provided with the
     14 // distribution.
     15 //     * Neither the name of Google Inc. nor the names of its
     16 // contributors may be used to endorse or promote products derived from
     17 // this software without specific prior written permission.
     18 //
     19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30 
     31 // Author: wink (a] google.com (Wink Saville)
     32 
     33 package protobuf_unittest;
     34 
     35 import "google/protobuf/unittest_import_nano.proto";
     36 
     37 option java_package = "com.google.protobuf.nano";
     38 option java_outer_classname = "NanoOuterClass";
     39 
     40 // Same as TestAllTypes but with the nano runtime.
     41 message TestAllTypesNano {
     42 
     43   message NestedMessage {
     44     optional int32 bb = 1;
     45   }
     46 
     47   enum NestedEnum {
     48     FOO = 1;
     49     BAR = 2;
     50     BAZ = 3;
     51   }
     52 
     53   // Singular
     54   optional    int32 optional_int32    =  1;
     55   optional    int64 optional_int64    =  2;
     56   optional   uint32 optional_uint32   =  3;
     57   optional   uint64 optional_uint64   =  4;
     58   optional   sint32 optional_sint32   =  5;
     59   optional   sint64 optional_sint64   =  6;
     60   optional  fixed32 optional_fixed32  =  7;
     61   optional  fixed64 optional_fixed64  =  8;
     62   optional sfixed32 optional_sfixed32 =  9;
     63   optional sfixed64 optional_sfixed64 = 10;
     64   optional    float optional_float    = 11;
     65   optional   double optional_double   = 12;
     66   optional     bool optional_bool     = 13;
     67   optional   string optional_string   = 14;
     68   optional    bytes optional_bytes    = 15;
     69 
     70   optional group OptionalGroup = 16 {
     71     optional int32 a = 17;
     72   }
     73 
     74   optional NestedMessage      optional_nested_message  = 18;
     75   optional ForeignMessageNano optional_foreign_message = 19;
     76   optional protobuf_unittest_import.ImportMessageNano
     77     optional_import_message = 20;
     78 
     79   optional NestedEnum      optional_nested_enum     = 21;
     80   optional ForeignEnumNano optional_foreign_enum    = 22;
     81   optional protobuf_unittest_import.ImportEnumNano optional_import_enum = 23;
     82 
     83   optional string optional_string_piece = 24 [ctype=STRING_PIECE];
     84   optional string optional_cord = 25 [ctype=CORD];
     85 
     86   // Repeated
     87   repeated    int32 repeated_int32    = 31;
     88   repeated    int64 repeated_int64    = 32;
     89   repeated   uint32 repeated_uint32   = 33;
     90   repeated   uint64 repeated_uint64   = 34;
     91   repeated   sint32 repeated_sint32   = 35;
     92   repeated   sint64 repeated_sint64   = 36;
     93   repeated  fixed32 repeated_fixed32  = 37;
     94   repeated  fixed64 repeated_fixed64  = 38;
     95   repeated sfixed32 repeated_sfixed32 = 39;
     96   repeated sfixed64 repeated_sfixed64 = 40;
     97   repeated    float repeated_float    = 41;
     98   repeated   double repeated_double   = 42;
     99   repeated     bool repeated_bool     = 43;
    100   repeated   string repeated_string   = 44;
    101   repeated    bytes repeated_bytes    = 45;
    102 
    103   repeated group RepeatedGroup = 46 {
    104     optional int32 a = 47;
    105   }
    106 
    107   repeated NestedMessage      repeated_nested_message  = 48;
    108   repeated ForeignMessageNano repeated_foreign_message = 49;
    109   repeated protobuf_unittest_import.ImportMessageNano
    110     repeated_import_message = 50;
    111 
    112   repeated NestedEnum      repeated_nested_enum  = 51;
    113   repeated ForeignEnumNano repeated_foreign_enum = 52;
    114   repeated protobuf_unittest_import.ImportEnumNano repeated_import_enum = 53;
    115 
    116   repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
    117   repeated string repeated_cord = 55 [ctype=CORD];
    118 
    119   // Repeated packed
    120   repeated    int32 repeated_packed_int32    = 87 [packed=true];
    121   repeated sfixed64 repeated_packed_sfixed64 = 88 [packed=true];
    122 
    123   repeated NestedEnum repeated_packed_nested_enum  = 89 [packed=true];
    124 
    125   // Singular with defaults
    126   optional    int32 default_int32    = 61 [default =  41    ];
    127   optional    int64 default_int64    = 62 [default =  42    ];
    128   optional   uint32 default_uint32   = 63 [default =  43    ];
    129   optional   uint64 default_uint64   = 64 [default =  44    ];
    130   optional   sint32 default_sint32   = 65 [default = -45    ];
    131   optional   sint64 default_sint64   = 66 [default =  46    ];
    132   optional  fixed32 default_fixed32  = 67 [default =  47    ];
    133   optional  fixed64 default_fixed64  = 68 [default =  48    ];
    134   optional sfixed32 default_sfixed32 = 69 [default =  49    ];
    135   optional sfixed64 default_sfixed64 = 70 [default = -50    ];
    136   optional    float default_float    = 71 [default =  51.5  ];
    137   optional   double default_double   = 72 [default =  52e3  ];
    138   optional     bool default_bool     = 73 [default = true   ];
    139   optional   string default_string   = 74 [default = "hello"];
    140   optional    bytes default_bytes    = 75 [default = "world"];
    141 
    142   optional string default_string_nonascii = 76 [default = "dnya"];
    143   optional  bytes default_bytes_nonascii  = 77 [default = "dnyab"];
    144 
    145   optional  float default_float_inf      = 97  [default =  inf];
    146   optional  float default_float_neg_inf  = 98  [default = -inf];
    147   optional  float default_float_nan      = 99  [default =  nan];
    148   optional double default_double_inf     = 100 [default =  inf];
    149   optional double default_double_neg_inf = 101 [default = -inf];
    150   optional double default_double_nan     = 102 [default =  nan];
    151 
    152   optional NestedEnum default_nested_enum = 81 [default = BAR];
    153   optional ForeignEnumNano default_foreign_enum = 82
    154       [default = FOREIGN_NANO_BAR];
    155   optional protobuf_unittest_import.ImportEnumNano
    156       default_import_enum = 83 [default = IMPORT_NANO_BAR];
    157 
    158   optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
    159   optional string default_cord = 85 [ctype=CORD,default="123"];
    160 
    161   required int32 id = 86;
    162 
    163   // Try to cause conflicts.
    164   optional int32 tag = 93;
    165   optional int32 get_serialized_size = 94;
    166   optional int32 write_to = 95;
    167 
    168   // Try to fail with java reserved keywords
    169   optional int32 synchronized = 96;
    170 }
    171 
    172 message ForeignMessageNano {
    173   optional int32 c = 1;
    174 }
    175 
    176 enum ForeignEnumNano {
    177   FOREIGN_NANO_FOO = 4;
    178   FOREIGN_NANO_BAR = 5;
    179   FOREIGN_NANO_BAZ = 6;
    180 }
    181 
    182 // Test that deprecated fields work.  We only verify that they compile (at one
    183 // point this failed).
    184 message TestDeprecatedNano {
    185   optional int32 deprecated_field = 1 [deprecated = true];
    186 }
    187