@@ -128,13 +128,7 @@ class Test_Unknown_proto2: XCTestCase, PBTestHelpers {
128128
129129
130130 func assertUnknownFields( _ message: Proto2Message , _ bytes: [ UInt8 ] , line: UInt = #line) {
131- var collector = UnknownCollector ( )
132- do {
133- try message. unknownFields. traverse ( visitor: & collector)
134- } catch let e {
135- XCTFail ( " Throw why walking unknowns: \( e) " , line: line)
136- }
137- XCTAssertEqual ( collector. collected, [ Data ( bytes: bytes) ] , line: line)
131+ XCTAssertEqual ( message. unknownFields. data, Data ( bytes: bytes) , line: line)
138132 }
139133
140134 func test_MessageNoStorageClass( ) throws {
@@ -181,46 +175,3 @@ class Test_Unknown_proto2: XCTestCase, PBTestHelpers {
181175 assertUnknownFields ( msg1, [ 24 , 1 , 61 , 7 , 0 , 0 , 0 ] )
182176 }
183177}
184-
185- // Helper visitor class that ignores everything, but collects the
186- // things passed to visitUnknown.
187- struct UnknownCollector : Visitor {
188- var collected : [ Data ] = [ ]
189-
190- mutating func visitUnknown( bytes: Data ) {
191- collected. append ( bytes)
192- }
193-
194- mutating func visitSingularDoubleField( value: Double , fieldNumber: Int ) throws { }
195-
196- mutating func visitSingularInt64Field( value: Int64 , fieldNumber: Int ) throws { }
197-
198- mutating func visitSingularUInt64Field( value: UInt64 , fieldNumber: Int ) throws { }
199-
200- mutating func visitSingularBoolField( value: Bool , fieldNumber: Int ) throws { }
201-
202- mutating func visitSingularStringField( value: String , fieldNumber: Int ) throws { }
203-
204- mutating func visitSingularBytesField( value: Data , fieldNumber: Int ) throws { }
205-
206- mutating func visitSingularEnumField< E: Enum > ( value: E , fieldNumber: Int ) throws { }
207-
208- mutating func visitSingularMessageField< M: Message > ( value: M , fieldNumber: Int ) throws { }
209-
210- mutating func visitMapField< KeyType: MapKeyType , ValueType: MapValueType > (
211- fieldType: _ProtobufMap < KeyType , ValueType > . Type ,
212- value: _ProtobufMap < KeyType , ValueType > . BaseType ,
213- fieldNumber: Int ) throws where KeyType. BaseType: Hashable { }
214-
215- mutating func visitMapField< KeyType: MapKeyType , ValueType: Enum > (
216- fieldType: _ProtobufEnumMap < KeyType , ValueType > . Type ,
217- value: _ProtobufEnumMap < KeyType , ValueType > . BaseType ,
218- fieldNumber: Int ) throws where KeyType. BaseType: Hashable , ValueType. RawValue == Int { }
219-
220- mutating func visitMapField< KeyType: MapKeyType , ValueType: Message > (
221- fieldType: _ProtobufMessageMap < KeyType , ValueType > . Type ,
222- value: _ProtobufMessageMap < KeyType , ValueType > . BaseType ,
223- fieldNumber: Int ) throws where KeyType. BaseType: Hashable { }
224-
225- mutating func visitExtensionFields( fields: ExtensionFieldValueSet , start: Int , end: Int ) throws { }
226- }
0 commit comments