-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathprotobuf_enumerated.rs
98 lines (85 loc) · 1.81 KB
/
protobuf_enumerated.rs
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
mod test_utils;
use test_utils::*;
asn_to_rust!(
r"MyDef DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
ProtobufEnum ::= SEQUENCE {
some-enum ENUMERATED {
A,
B,
C
}
}
ProtobufEnumExt ::= SEQUENCE {
lone-bool BOOLEAN,
some-enum ENUMERATED {
A,
B,
C
},
lone-int INTEGER
}
ProtobufOuterEnum ::= ENUMERATED {
A,
B,
C
}
END"
);
#[test]
#[cfg(feature = "protobuf")]
fn test_enumeration_a() {
serialize_and_deserialize_protobuf(
&[8, 0],
&ProtobufEnum {
some_enum: ProtobufEnumSomeEnum::A,
},
)
}
#[test]
#[cfg(feature = "protobuf")]
fn test_enumeration_b() {
serialize_and_deserialize_protobuf(
&[8, 1],
&ProtobufEnum {
some_enum: ProtobufEnumSomeEnum::B,
},
)
}
#[test]
#[cfg(feature = "protobuf")]
fn test_enumeration_c() {
serialize_and_deserialize_protobuf(
&[8, 2],
&ProtobufEnum {
some_enum: ProtobufEnumSomeEnum::C,
},
)
}
#[test]
#[cfg(feature = "protobuf")]
fn test_enumeration_ext_b() {
serialize_and_deserialize_protobuf(
&[8, 0, 16, 1, 24, 217, 2],
&ProtobufEnumExt {
lone_bool: false,
some_enum: ProtobufEnumExtSomeEnum::B,
lone_int: 345_u64,
},
)
}
#[test]
#[cfg(feature = "protobuf")]
fn test_enumeration_outer_a() {
serialize_and_deserialize_protobuf(&[0], &ProtobufOuterEnum::A)
}
#[test]
#[cfg(feature = "protobuf")]
fn test_enumeration_outer_b() {
serialize_and_deserialize_protobuf(&[1], &ProtobufOuterEnum::B)
}
#[test]
#[cfg(feature = "protobuf")]
fn test_enumeration_outer_c() {
serialize_and_deserialize_protobuf(&[2], &ProtobufOuterEnum::C)
}