-
Notifications
You must be signed in to change notification settings - Fork 13.3k
additional edge cases tests for path.rs
🧪
#141105
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
It appears that |
|
It looks as if |
Yes, please fix the tests to only use functions from OsStr and OsString OR cfg the tests. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
tp!("foo./.", "bar", r"foo./.\bar"); | ||
tp!("foo./.", "bar", r"foo././bar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changing an existing test?
// Test: Reserved device names (Windows) | ||
// This test ensures that reserved device names like "CON", "PRN", etc., are handled as normal paths on non-Windows platforms, | ||
// and as special cases on Windows (if applicable). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't seem to describe the test.
// Test: Trailing dots/spaces (Windows) | ||
// This test checks how Path handles trailing dots or spaces, which are special on Windows. | ||
// On Unix, these should be treated as normal characters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path
mostly works the same across platforms (separator differences and roots/prefixes not withstanding). If there's a difference then you should have tests for both Windows and non-Windows that shows the difference.
// Test: Only extension (e.g., ".gitignore") | ||
// This test verifies that files with only an extension and no base name are handled correctly. | ||
// It checks that the extension is recognized and the file stem is None or empty as appropriate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really not have a test for this anywhere else?
// Test: Long components | ||
// This test checks that Path can handle very long path components without truncation or error. | ||
// It ensures that the length of the component is preserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this would be useful for us specifically? We don't usually check that slice wrappers work on the whole slice.
This pull request adds a few new edge case tests to the
std::path
module. The new tests cover scenarios such as paths with only separators, non-ASCII and Unicode characters, embedded null bytes, etc. Each new test is documented with some helpful in-line comments as well.