Skip to content

Migrate URL and String utility tests to Swift Testing#1547

Open
franklinsch wants to merge 10 commits into
swiftlang:mainfrom
franklinsch:migrate-url-and-string-utility-tests-to-swift-testing
Open

Migrate URL and String utility tests to Swift Testing#1547
franklinsch wants to merge 10 commits into
swiftlang:mainfrom
franklinsch:migrate-url-and-string-utility-tests-to-swift-testing

Conversation

@franklinsch

Copy link
Copy Markdown
Contributor

Bug/issue #, if applicable: N/A

Summary

Migrates utility tests for URL and String utilities to Swift Testing.

Dependencies

N/A

Testing

No functional change

Checklist

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@franklinsch franklinsch requested a review from a team as a code owner June 12, 2026 15:23
@franklinsch franklinsch force-pushed the migrate-url-and-string-utility-tests-to-swift-testing branch from 6d3b9aa to b4116c9 Compare June 12, 2026 15:29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: Many tests in this file could benefit from both parameterization and a more descriptive test name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the expectations that have a comment associated to them, I left them as is so that we preserve it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: The tests in this file could benefit from more descriptive test names.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: The tests in this file could benefit from slightly more descriptive test names.

Comment on lines +16 to +23
@Test
func splitsAStringWithNoTrailingNewlines() {
#expect("hello\nworld".splitByNewlines == ["hello", "world"])
}

func testSplitsAStringWithOneTrailingNewline() {
XCTAssertEqual("hello\nworld\n".splitByNewlines, ["hello", "world"])
@Test
func splitsAStringWithOneTrailingNewline() {
#expect("hello\nworld\n".splitByNewlines == ["hello", "world"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: These two tests could be combined into a single parameterized test.

Comment on lines +16 to +17
@Test
func variousSeparators() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: This could benefit from parameterization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are great suggestions, thanks. I'll address these as part of this PR.

@franklinsch franklinsch force-pushed the migrate-url-and-string-utility-tests-to-swift-testing branch from b4116c9 to 8ca587b Compare June 12, 2026 15:57
@franklinsch franklinsch force-pushed the migrate-url-and-string-utility-tests-to-swift-testing branch from 8ca587b to 5d5bfe7 Compare June 12, 2026 15:59
@franklinsch

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

Comment on lines +32 to +36
("hello, world", "Hello, world"),
("twenty-one", "Twenty-One"),
("hello! world", "Hello! world"),
("hello: world", "Hello: world"),
("l'ocean world", "L'ocean world"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: You can write this as a dictionary literal as well

Suggested change
("hello, world", "Hello, world"),
("twenty-one", "Twenty-One"),
("hello! world", "Hello! world"),
("hello: world", "Hello: world"),
("l'ocean world", "L'ocean world"),
"hello, world": "Hello, world",
"twenty-one": "Twenty-One",
"hello! world": "Hello! world",
"hello: world": "Hello: world",
"l'ocean world": "L'ocean world",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good to know. Do you feel like that is more idiomatic?

func testUSRHash() {
// Test that the results are stable for the given inputs
@Test(arguments: [
("", "ztntfp"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: do you know why ExternalIdentifier.usr("").hash is expected to produce a different value compared to "".stableHashString?

I can see in the implementation that ExternalIdentifier.usr("").hash doesn't "fold" the hash into 24 bits before converting it to a base 36 string, but without a code comment in the implementation that feels like a possible bug to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants