-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sanity check for separate translation unit.
- Loading branch information
Showing
2 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "test.h" | ||
|
||
zpp::throwing<bool> integer_divide_equals(int x, int y, int z); | ||
|
||
static int test_integer_divide_equals(int x, int y, int z) | ||
{ | ||
return zpp::try_catch([&]() -> zpp::throwing<int> { | ||
if (co_await integer_divide_equals(x, y, z)) { | ||
co_return 1; | ||
} else { | ||
co_return 2; | ||
} | ||
}, [&](const std::overflow_error &) { | ||
return 3; | ||
}, [&](const std::range_error &) { | ||
return 4; | ||
}, [&]() { | ||
return 5; | ||
}); | ||
} | ||
|
||
TEST(sanity_integer_divide, integer_divide_separate_tu) | ||
{ | ||
EXPECT_EQ(test_integer_divide_equals(4, 2, 2), 1); | ||
EXPECT_EQ(test_integer_divide_equals(4, 2, 1), 2); | ||
EXPECT_EQ(test_integer_divide_equals(4, 0, 2), 3); | ||
EXPECT_EQ(test_integer_divide_equals(4, 3, 2), 4); | ||
} | ||
|