Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some more swift-format lint issues. #1725

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,21 @@ final class Test_Descriptor_FeatureResolution: XCTestCase {
XCTAssertEqual(oneofFieldFeatures.SwiftFeatureTest_test.feature2, .value3) // Message override
XCTAssertEqual(oneofFieldFeatures.SwiftFeatureTest_test.feature3, .value4) // Oneof override
XCTAssertEqual(oneofFieldFeatures.SwiftFeatureTest_test.feature4, .value5) // "oneof_field" Field override
XCTAssertEqual(oneofFieldFeatures.SwiftFeatureTest_test.feature5, .value1) // default ("not_oneof_field" Field override)
XCTAssertEqual(
oneofFieldFeatures.SwiftFeatureTest_test.feature5, // default ("not_oneof_field" Field override)
.value1
)
let field = context.file.messages.first!.fields[1]
XCTAssertEqual(field.name, "not_oneof_field")
let fieldFeatures = field.features
XCTAssertTrue(fieldFeatures.hasSwiftFeatureTest_test)
XCTAssertEqual(fieldFeatures.SwiftFeatureTest_test.feature1, .value2) // File override
XCTAssertEqual(fieldFeatures.SwiftFeatureTest_test.feature2, .value3) // Message override
XCTAssertEqual(fieldFeatures.SwiftFeatureTest_test.feature3, .value1) // default (Oneof override)
XCTAssertEqual(fieldFeatures.SwiftFeatureTest_test.feature4, .value1) // default ("oneof_field" Field override)
XCTAssertEqual(
fieldFeatures.SwiftFeatureTest_test.feature4, // default ("oneof_field" Field override)
.value1
)
XCTAssertEqual(fieldFeatures.SwiftFeatureTest_test.feature5, .value6) // "not_oneof_field" Field override
}

Expand Down
21 changes: 16 additions & 5 deletions Tests/SwiftProtobufTests/Test_AllTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1196,10 +1196,16 @@ final class Test_AllTypes: XCTestCase, PBTestHelpers {
assertDecodesAsUnknownFields([152, 1, 0]) // Wrong wire type (varint), valid as an unknown field
assertDecodeFails([153, 1]) // Wire type 1
assertDecodeFails([153, 1, 0])
assertDecodesAsUnknownFields([153, 1, 0, 0, 0, 0, 0, 0, 0, 0]) // Wrong wire type (fixed64), valid as an unknown field
assertDecodesAsUnknownFields([
153, 1, // Wrong wire type (fixed64), valid as an unknown field
0, 0, 0, 0, 0, 0, 0, 0,
])
assertDecodeFails([155, 1]) // Wire type 3
assertDecodeFails([155, 1, 0])
assertDecodesAsUnknownFields([155, 1, 156, 1]) // Wrong wire type (start group, end group), valid as an unknown field
assertDecodesAsUnknownFields([
155, 1, // Wrong wire type (start group, end group), valid as an unknown field
156, 1,
])
assertDecodeFails([156, 1]) // Wire type 4
assertDecodeFails([156, 1, 0])
assertDecodeFails([157, 1]) // Wire type 5
Expand Down Expand Up @@ -2600,7 +2606,10 @@ final class Test_AllTypes: XCTestCase, PBTestHelpers {
assertMergesAsUnknownFields([136, 7, 1], inTo: initialMsg) {
$0.oneofUint32 == 123 // Shouldn't have gotten cleared.
}
assertDecodesAsUnknownFields([137, 7, 1, 1, 1, 1, 1, 1, 1, 1]) { // Wrong wire type (fixed64), valid as an unknown field
assertDecodesAsUnknownFields([
137, 7, // Wrong wire type (fixed64), valid as an unknown field
1, 1, 1, 1, 1, 1, 1, 1,
]) {
$0.oneofField == nil // oneof doesn't get set.
}
assertMergesAsUnknownFields([137, 7, 1, 1, 1, 1, 1, 1, 1, 1], inTo: initialMsg) {
Expand Down Expand Up @@ -2790,7 +2799,8 @@ final class Test_AllTypes: XCTestCase, PBTestHelpers {
([197, 12, 30, 0, 0, 0], "200: 0x0000001E"), // fixed32.

([192, 12, 129, 1], "200: 129"), // varint of 129 (two bytes on wire).
([195, 12, 11, 8, 1, 12, 196, 12], "200 {\n 1 {\n 1: 1\n }\n}"), // StartGroup, Field 1: StartGroup, Field 1: varint of 1, EndGroup, EndGroup.
// StartGroup, Field 1: StartGroup, Field 1: varint of 1, EndGroup, EndGroup.
([195, 12, 11, 8, 1, 12, 196, 12], "200 {\n 1 {\n 1: 1\n }\n}"),
]

// Fields at the top level of the message.
Expand Down Expand Up @@ -2862,7 +2872,8 @@ final class Test_AllTypes: XCTestCase, PBTestHelpers {

[195, 12, 11], // StartGroup, Field 1: StartGroup.
[195, 12, 11, 8, 1, 12], // StartGroup, Field 1: StartGroup, Field 1: varint of 1, EndGroup.
[195, 12, 11, 8, 1, 196, 12], // StartGroup, Field 1: StartGroup, Field 1: varint of 1, EndGroup (but wrong group).
// StartGroup, Field 1: StartGroup, Field 1: varint of 1, EndGroup (but wrong group).
[195, 12, 11, 8, 1, 196, 12],
]

// Fields at the top level of the message.
Expand Down
15 changes: 12 additions & 3 deletions Tests/SwiftProtobufTests/Test_AllTypes_Proto3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,16 @@ final class Test_AllTypes_Proto3: XCTestCase, PBTestHelpers {
assertDecodesAsUnknownFields([152, 1, 0]) // Wrong wire type (varint), valid as an unknown field
assertDecodeFails([153, 1]) // Wire type 1
assertDecodeFails([153, 1, 0])
assertDecodesAsUnknownFields([153, 1, 0, 0, 0, 0, 0, 0, 0, 0]) // Wrong wire type (fixed64), valid as an unknown field
assertDecodesAsUnknownFields([
153, 1, // Wrong wire type (fixed64), valid as an unknown field
0, 0, 0, 0, 0, 0, 0, 0,
])
assertDecodeFails([155, 1]) // Wire type 3
assertDecodeFails([155, 1, 0])
assertDecodesAsUnknownFields([155, 1, 156, 1]) // Wrong wire type (start group, end group), valid as an unknown field
assertDecodesAsUnknownFields([
155, 1, // Wrong wire type (start group, end group), valid as an unknown field
156, 1,
])
assertDecodeFails([156, 1]) // Wire type 4
assertDecodeFails([156, 1, 0])
assertDecodeFails([157, 1]) // Wire type 5
Expand Down Expand Up @@ -1452,7 +1458,10 @@ final class Test_AllTypes_Proto3: XCTestCase, PBTestHelpers {
assertDecodesAsUnknownFields([136, 7, 1]) { // Wrong wire type (varint), valid as an unknown field
$0.oneofField == nil // oneof doesn't get set.
}
assertDecodesAsUnknownFields([137, 7, 1, 1, 1, 1, 1, 1, 1, 1]) { // Wrong wire type (fixed64), valid as an unknown field
assertDecodesAsUnknownFields([
137, 7, // Wrong wire type (fixed64), valid as an unknown field
1, 1, 1, 1, 1, 1, 1, 1,
]) {
$0.oneofField == nil // oneof doesn't get set.
}
assertDecodeFails([139, 7]) // Wire type 3
Expand Down
5 changes: 4 additions & 1 deletion Tests/SwiftProtobufTests/Test_Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ final class Test_Extensions: XCTestCase, PBTestHelpers {
assertDecodeSucceeds([8, 99]) { $0.SwiftProtoTesting_optionalInt32Extension == 99 }
assertDecodeFails([9])
assertDecodeFails([9, 0])
assertDecodesAsUnknownFields([9, 0, 0, 0, 0, 0, 0, 0, 0]) // Wrong wire type (fixed64), valid as an unknown field
assertDecodesAsUnknownFields([
9, // Wrong wire type (fixed64), valid as an unknown field
0, 0, 0, 0, 0, 0, 0, 0,
])
assertDecodeFails([10])
assertDecodesAsUnknownFields([10, 0]) // Wrong wire type (length delimited), valid as an unknown field
assertDecodeFails([11])
Expand Down
6 changes: 3 additions & 3 deletions Tests/SwiftProtobufTests/Test_TextFormatDecodingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class Test_TextFormatDecodingOptions: XCTestCase {
var options = TextFormatDecodingOptions()
options.ignoreUnknownFields = true

let msg = try SwiftProtoTesting_TestAllTypes(textFormatString: textInputField, options: options) // Shouldn't fail
let msg = try SwiftProtoTesting_TestAllTypes(textFormatString: textInputField, options: options)
XCTAssertEqual(msg.textFormatString(), "optional_int32: 2\n")

do {
Expand All @@ -84,7 +84,7 @@ final class Test_TextFormatDecodingOptions: XCTestCase {
// This is what should have happened.
}

let msg = try SwiftProtoTesting_TestAllTypes(textFormatString: textInputExtField, options: options) // Shouldn't fail
let msg = try SwiftProtoTesting_TestAllTypes(textFormatString: textInputExtField, options: options)
XCTAssertEqual(msg.textFormatString(), "optional_int32: 2\n")
}

Expand All @@ -95,7 +95,7 @@ final class Test_TextFormatDecodingOptions: XCTestCase {
options.ignoreUnknownFields = true
options.ignoreUnknownExtensionFields = true

let msg = try SwiftProtoTesting_TestAllTypes(textFormatString: textInput, options: options) // Shouldn't fail
let msg = try SwiftProtoTesting_TestAllTypes(textFormatString: textInput, options: options)
XCTAssertEqual(msg.textFormatString(), "optional_int32: 2\n")
}

Expand Down