aboutsummaryrefslogtreecommitdiffstats
path: root/tests/enum_sizes/enumsizes.proto
blob: f9ab0b7f52ed80aef5e5c29f8c2dc077bc16650a (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Test handling of enums with different value ranges.
 * Depending on compiler and the packed_enum setting, the datatypes
 * for enums can be either signed or unsigned. In past this has caused
 * a bit of a problem for the encoder/decoder (issue #164).
 */

import 'nanopb.proto';

option (nanopb_fileopt).long_names = false;

enum UnpackedUint8 {
    option (nanopb_enumopt).packed_enum = false;
    UU8_MIN = 0;
    UU8_MAX = 255;
}

enum PackedUint8 {
    option (nanopb_enumopt).packed_enum = true;
    PU8_MIN = 0;
    PU8_MAX = 255;
}

enum UnpackedInt8 {
    option (nanopb_enumopt).packed_enum = false;
    UI8_MIN = -128;
    UI8_MAX = 127;
}

enum PackedInt8 {
    option (nanopb_enumopt).packed_enum = true;
    PI8_MIN = -128;
    PI8_MAX = 127;
}

enum UnpackedUint16 {
    option (nanopb_enumopt).packed_enum = false;
    UU16_MIN = 0;
    UU16_MAX = 65535;
}

enum PackedUint16 {
    option (nanopb_enumopt).packed_enum = true;
    PU16_MIN = 0;
    PU16_MAX = 65535;
}

enum UnpackedInt16 {
    option (nanopb_enumopt).packed_enum = false;
    UI16_MIN = -32768;
    UI16_MAX = 32767;
}

enum PackedInt16 {
    option (nanopb_enumopt).packed_enum = true;
    PI16_MIN = -32768;
    PI16_MAX = 32767;
}

/* Protobuf supports enums up to 32 bits.
 * The 32 bit case is covered by HugeEnum in the alltypes test.
 */

message PackedEnums {
    required PackedUint8  u8_min  = 1;
    required PackedUint8  u8_max  = 2;
    required PackedInt8   i8_min  = 3;
    required PackedInt8   i8_max  = 4;
    required PackedUint16 u16_min = 5;
    required PackedUint16 u16_max = 6;
    required PackedInt16  i16_min = 7;
    required PackedInt16  i16_max = 8;
}

message UnpackedEnums {
    required UnpackedUint8  u8_min  = 1;
    required UnpackedUint8  u8_max  = 2;
    required UnpackedInt8   i8_min  = 3;
    required UnpackedInt8   i8_max  = 4;
    required UnpackedUint16 u16_min = 5;
    required UnpackedUint16 u16_max = 6;
    required UnpackedInt16  i16_min = 7;
    required UnpackedInt16  i16_max = 8;
}