@@ -15,7 +15,7 @@ typedef RoundtripTester<T> = void Function(T value, List<int> bytes);
1515void main () {
1616 ByteData makeData (Uint8List bytes) => ByteData .view (bytes.buffer);
1717
18- Uint8List Function (dynamic ) convertToBytes (fieldType) => (value) {
18+ Uint8List Function (dynamic ) convertToBytes (FieldType fieldType) => (value) {
1919 var writer = CodedBufferWriter ()..writeField (0 , fieldType, value);
2020 return writer.toBuffer ().sublist (1 );
2121 };
@@ -29,7 +29,7 @@ void main() {
2929 };
3030 }
3131
32- final int32ToBytes = convertToBytes (PbFieldType . O3 );
32+ final int32ToBytes = convertToBytes (FieldType . OPTIONAL_I32 () );
3333
3434 test ('testInt32RoundTrips' , () {
3535 final roundtrip = roundtripTester (
@@ -49,7 +49,7 @@ void main() {
4949 test ('testSint32' , () {
5050 final roundtrip = roundtripTester (
5151 fromBytes: (CodedBufferReader reader) => reader.readSint32 (),
52- toBytes: convertToBytes (PbFieldType . OS3 ));
52+ toBytes: convertToBytes (FieldType . optional ( FieldBaseType .sint32) ));
5353
5454 roundtrip (0 , [0x00 ]);
5555 roundtrip (- 1 , [0x01 ]);
@@ -60,7 +60,7 @@ void main() {
6060 test ('testSint64' , () {
6161 final roundtrip = roundtripTester (
6262 fromBytes: (CodedBufferReader reader) => reader.readSint64 (),
63- toBytes: convertToBytes (PbFieldType . OS6 ));
63+ toBytes: convertToBytes (FieldType . optional ( FieldBaseType .sint64) ));
6464
6565 roundtrip (make64 (0 ), [0x00 ]);
6666 roundtrip (make64 (- 1 ), [0x01 ]);
@@ -71,7 +71,7 @@ void main() {
7171 test ('testFixed32' , () {
7272 final roundtrip = roundtripTester (
7373 fromBytes: (CodedBufferReader reader) => reader.readFixed32 (),
74- toBytes: convertToBytes (PbFieldType . OF3 ));
74+ toBytes: convertToBytes (FieldType . optional ( FieldBaseType .fixed32) ));
7575
7676 roundtrip (0 , [0x00 , 0x00 , 0x00 , 0x00 ]);
7777 roundtrip (1 , [0x01 , 0x00 , 0x00 , 0x00 ]);
@@ -82,7 +82,7 @@ void main() {
8282 test ('testFixed64' , () {
8383 final roundtrip = roundtripTester (
8484 fromBytes: (CodedBufferReader reader) => reader.readFixed64 (),
85- toBytes: convertToBytes (PbFieldType . OF6 ));
85+ toBytes: convertToBytes (FieldType . optional ( FieldBaseType .fixed64) ));
8686
8787 roundtrip (make64 (0 , 0 ), [0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ]);
8888 roundtrip (make64 (1 , 0 ), [0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ]);
@@ -95,7 +95,7 @@ void main() {
9595 test ('testSfixed32' , () {
9696 final roundtrip = roundtripTester (
9797 fromBytes: (CodedBufferReader reader) => reader.readSfixed32 (),
98- toBytes: convertToBytes (PbFieldType . OSF3 ));
98+ toBytes: convertToBytes (FieldType . optional ( FieldBaseType .fixed32) ));
9999
100100 roundtrip (0 , [0x00 , 0x00 , 0x00 , 0x00 ]);
101101 roundtrip (1 , [0x01 , 0x00 , 0x00 , 0x00 ]);
@@ -106,7 +106,7 @@ void main() {
106106 test ('testSfixed64' , () {
107107 final roundtrip = roundtripTester (
108108 fromBytes: (CodedBufferReader reader) => reader.readSfixed64 (),
109- toBytes: convertToBytes (PbFieldType . OSF6 ));
109+ toBytes: convertToBytes (FieldType . optional ( FieldBaseType .sfixed64) ));
110110
111111 roundtrip (make64 (0 ), [0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ]);
112112 roundtrip (make64 (- 1 ), [0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff ]);
@@ -133,7 +133,7 @@ void main() {
133133 : equals (expected);
134134
135135 List <int > dataToBytes (ByteData byteData) => Uint8List .view (byteData.buffer);
136- final floatToBytes = convertToBytes (PbFieldType . OF );
136+ final floatToBytes = convertToBytes (FieldType . optional ( FieldBaseType .float) );
137137 int floatToBits (double value) =>
138138 makeData (floatToBytes (value)).getUint32 (0 , Endian .little);
139139
@@ -147,7 +147,8 @@ void main() {
147147 expect (readFloat (bits), doubleEquals (value));
148148 }
149149
150- final doubleToBytes = convertToBytes (PbFieldType .OD );
150+ final doubleToBytes =
151+ convertToBytes (FieldType .optional (FieldBaseType .double ));
151152
152153 void _test64 (List <int > hilo, double value) {
153154 // Encode a double to its wire format.
@@ -682,7 +683,7 @@ void main() {
682683 test ('testVarint64' , () {
683684 final roundtrip = roundtripTester (
684685 fromBytes: (CodedBufferReader reader) => reader.readUint64 (),
685- toBytes: convertToBytes (PbFieldType . OU6 ));
686+ toBytes: convertToBytes (FieldType . optional ( FieldBaseType .uint64) ));
686687
687688 roundtrip (make64 (0 ), [0x00 ]);
688689 roundtrip (make64 (3 ), [0x03 ]);
0 commit comments