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

testRandomUuid: use cppunit exception tests #1814

Closed
wants to merge 1 commit into from

Conversation

kinkie
Copy link
Contributor

@kinkie kinkie commented May 18, 2024

Do not hand-roll tests for exception-throwing code

Do not hand-roll tests for exception-throwing code,
use the CppUnit primitives instead
@kinkie
Copy link
Contributor Author

kinkie commented May 18, 2024

Followup to PR #1811

@kinkie kinkie added the backport-to-v6 maintainer has approved these changes for v6 backporting label May 18, 2024
rousskov
rousskov previously approved these changes May 18, 2024
continue; // success, caught a malformed UUID
}
CPPUNIT_FAIL("failed to reject an invalid UUID");
CPPUNIT_ASSERT_THROW(RandomUuid uuid(id.second), TextException);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit worried that uuid is now seemingly unused, but since compilers do not seem to think so, I am OK with the current PR code.

FWIW, I would prefer something more explicit like the code below, but I do not know whether it would work.

Suggested change
CPPUNIT_ASSERT_THROW(RandomUuid uuid(id.second), TextException);
CPPUNIT_ASSERT_THROW((void)RandomUuid(id.second), TextException);

Copy link
Contributor

Choose a reason for hiding this comment

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

I expect the compilers are smart enough to notice that the RandomUuid has external side effects on the shared/static RNG engine.

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) S-could-use-an-approval An approval may speed this PR merger (but is not required) labels May 18, 2024
yadij
yadij previously approved these changes May 19, 2024
@yadij yadij added M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels and removed S-waiting-for-author author action is expected (and usually required) S-could-use-an-approval An approval may speed this PR merger (but is not required) labels May 19, 2024
@kinkie kinkie dismissed stale reviews from yadij and rousskov via e166d29 May 20, 2024 05:13
@kinkie
Copy link
Contributor Author

kinkie commented May 20, 2024

Moving test_http_range changes to their own PR (#1816).
Re-requesting review

@rousskov rousskov added the S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box label May 20, 2024
@rousskov
Copy link
Contributor

Moving test_http_range changes to their own PR (#1816). Re-requesting review

My position on this PR has not changed: I have restored my approval, and my comment still applies.

@yadij yadij removed the S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box label May 22, 2024
squid-anubis pushed a commit that referenced this pull request May 22, 2024
Do not hand-roll tests for exception-throwing code
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label May 22, 2024
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels labels May 22, 2024
squidadm pushed a commit to squidadm/squid that referenced this pull request May 23, 2024
Do not hand-roll tests for exception-throwing code
@squidadm
Copy link
Collaborator

queued for backport to v6

@squidadm squidadm removed the backport-to-v6 maintainer has approved these changes for v6 backporting label May 23, 2024
yadij pushed a commit that referenced this pull request May 23, 2024
Do not hand-roll tests for exception-throwing code
kinkie added a commit to kinkie/squid that referenced this pull request Jun 2, 2024
Do not hand-roll tests for exception-throwing code
kinkie added a commit to kinkie/squid that referenced this pull request Jun 9, 2024
Do not hand-roll tests for exception-throwing code
@kinkie kinkie mentioned this pull request Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-merged https://github.com/measurement-factory/anubis#pull-request-labels
Projects
None yet
5 participants