@@ -195,7 +195,7 @@ final class Test_FieldMask: XCTestCase, PBTestHelpers {
195
195
XCTAssertEqual ( message. optionalInt32, 0 )
196
196
XCTAssertEqual ( message. optionalNestedMessage. bb, 2 )
197
197
198
- // Checks trim should does nothing with an empty fieldMask.
198
+ // Checks trim should do nothing with an empty fieldMask.
199
199
let r2 = message. trim ( fieldMask: . init( ) )
200
200
XCTAssertFalse ( r2)
201
201
@@ -208,6 +208,25 @@ final class Test_FieldMask: XCTestCase, PBTestHelpers {
208
208
XCTAssertFalse ( r4)
209
209
}
210
210
211
+ // Checks trim functionality for field masks when applies on a extensible message.
212
+ func testTrimFieldsOfMessageWithExtension( ) throws {
213
+ var message = SwiftProtoTesting_Fuzz_Message ( )
214
+ message. singularInt32 = 1
215
+ message. SwiftProtoTesting_Fuzz_singularInt32Ext = 1
216
+ let mask = Google_Protobuf_FieldMask ( protoPaths: [ " singularString " ] )
217
+
218
+ // Checks trim should retain extensions while removes other fields.
219
+ let r1 = message. trim ( fieldMask: mask)
220
+ XCTAssertTrue ( r1)
221
+ XCTAssertEqual ( message. SwiftProtoTesting_Fuzz_singularInt32Ext, . init( 1 ) )
222
+ XCTAssertEqual ( message. singularInt32, . init( 0 ) )
223
+
224
+ // Checks trim should do nothing (fields are already removed) and still retain extension fields.
225
+ let r2 = message. trim ( fieldMask: mask)
226
+ XCTAssertFalse ( r2)
227
+ XCTAssertEqual ( message. SwiftProtoTesting_Fuzz_singularInt32Ext, . init( 1 ) )
228
+ }
229
+
211
230
// Checks `isPathValid` func
212
231
// 1. Valid primitive path.
213
232
// 2. Valid nested path.
0 commit comments