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

unit_tests: fix strtoul unit test #9214

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/unit_tests/epee_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,6 @@ TEST(parsing, strtoul)
p = "q";
Copy link

Choose a reason for hiding this comment

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

This part of the test would be the most likely to break across systems: Per the man page, some systems report EINVAL here: "EINVAL (not in C99) The given base contains an unsupported value." The c++ function makes no mention of EINVAL, so perhaps whoever wrote this test suite wanted a way to determine the actual behavior in a given build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you meant to put this comment on the test immediately below this one, yeah? According to the C standard, strtoul should skip over whitespace. But yes, I agree with the general point, so I updated the commit to just remove the EXPECT_EQ(0) from the invalid character test.

endp = nullptr;
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
EXPECT_EQ(0, errno);
EXPECT_EQ(0, ul);
EXPECT_EQ(p, endp);

Expand Down