Skip to content

Conversation

@sornas
Copy link
Collaborator

@sornas sornas commented Feb 5, 2020

Commit ef67422 shows how failing tests are handled and shown. I figured printing tests that pass is unneccesary since you only really care about the tests that fail. The time is in CPU-time since clock_gettime is portable enough (supports both linux and mac) and has better-than-millisecond resolution. (At least I think it does, it's not easy to find a straight answer to which resolution certain methods has that's true for all platforms.)

@sornas sornas requested a review from FredTheDino February 5, 2020 00:44
@FredTheDino FredTheDino changed the title Basic test framework Best test framework Feb 7, 2020
@FredTheDino
Copy link
Owner

The reason you can't find a good answer for the resolution of clocks is that it varies, there isn't a way to get 'exactly' ms precision, you usually get something in the ballpark. But these tests shouldn't be too crazy, so ball park is good enough.

Copy link
Owner

@FredTheDino FredTheDino left a comment

Choose a reason for hiding this comment

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

It's a nice start, and it will work wonders for stability

@sornas sornas changed the title Best test framework Best test framework (pls no merge) Feb 8, 2020
@sornas sornas changed the title Best test framework (pls no merge) Best test framework Feb 8, 2020
@sornas sornas requested a review from FredTheDino February 8, 2020 01:06
namespace Test {

bool test_slow_test_false() {
int a = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe a sleep? Busy wait seems like a bad idea. It might also be optimized out by the compiler and might infact be quite a fast test. But of course that depends on the compiler.

@sornas
Copy link
Collaborator Author

sornas commented Feb 9, 2020 via email

@sornas
Copy link
Collaborator Author

sornas commented Feb 9, 2020

I think I prefer chrono over clock_gettime, it feels clearer what's happening. Let me know what you think.

@sornas sornas requested review from FredTheDino and removed request for FredTheDino February 9, 2020 00:45
Copy link
Owner

@FredTheDino FredTheDino left a comment

Choose a reason for hiding this comment

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

LGTM, nice to have some more tests!

Comment on lines +98 to +100
Result math_eq() {
return SKIP;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Put in some numbers and see if it actually works. It checks equality with a margin, usefull for floating point compares.

printf(RED "unexpected successes:" RESET " %3d\n", (failed_expected - failed));
printf(YELLOW "expected failures:" RESET " %3d\n", failed);
printf(YELLOW "skipped:" RESET " %3d\n", skipped);
printf("%d tests in %.2f ms\n", size - skipped, (elapsed.count() / 1e6));
Copy link
Owner

Choose a reason for hiding this comment

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

chrono, I personally wouldn't use it, but that doesn't mean its bad. This isn't critical code so I'm fine with this. It can get messy when you want to change to different time-formats, but you kinda skipp it here. But it is the "C++ way", and the usage looks good.

Copy link
Owner

@FredTheDino FredTheDino left a comment

Choose a reason for hiding this comment

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

I should place a reminder for pressing the submit button...

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.

3 participants