Skip to content

Commit

Permalink
msvs fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Jul 6, 2024
1 parent 97d5ce0 commit 28fb9f9
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tests/unit/src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const tst::set set("exception", [](tst::suite& suite) {

auto actual = utki::split(s, '\n');

constexpr size_t expected_size = 4;

tst::check_eq(actual.size(), expected_size, SL);

#if CFG_COMPILER == CFG_COMPILER_MSVC
#else
auto expected_prefix = " std::"sv;

std::vector<std::string> expected = {
Expand All @@ -55,12 +61,11 @@ const tst::set set("exception", [](tst::suite& suite) {
" std::logic_error: some logic error"s
};

tst::check_eq(actual.size(), expected.size(), SL);

for (auto ei = expected.begin(), ai = actual.begin(); ei != expected.end(); ++ei, ++ai) {
tst::check(utki::starts_with(*ai, expected_prefix), SL);
tst::check(utki::ends_with(*ai, *ei), SL);
}
#endif
});

suite.add("current_exception_to_string", []() {
Expand All @@ -72,7 +77,11 @@ const tst::set set("exception", [](tst::suite& suite) {
s = utki::current_exception_to_string(" "sv);
}

#if CFG_COMPILER == CFG_COMPILER_MSVC
tst::check_eq(s, " unknown exception"s, SL);
#else
tst::check_eq(s, " (anonymous namespace)::some_unknown_error"s, SL);
#endif
});

suite.add("stacked_exception_to_string", []() {
Expand All @@ -97,12 +106,21 @@ const tst::set set("exception", [](tst::suite& suite) {

auto actual = utki::split(s, '\n');

#if CFG_COMPILER == CFG_COMPILER_MSVC
std::vector<std::string> expected = {
" std::invalid_argument: some argument is invalid"s,
" std::runtime_error: some_runtime_error"s,
" std::logic_error: some logic error"s,
" unknown exception"s
};
#else
std::vector<std::string> expected = {
" std::invalid_argument: some argument is invalid"s,
" std::runtime_error: some_runtime_error"s,
" std::logic_error: some logic error"s,
" (anonymous namespace)::some_unknown_error"s
};
#endif

tst::check_eq(actual.size(), expected.size(), SL);

Expand Down Expand Up @@ -133,13 +151,23 @@ const tst::set set("exception", [](tst::suite& suite) {

auto actual = utki::split(s, '\n');

#if CFG_COMPILER == CFG_COMPILER_MSVC
std::vector<std::string> expected = {
"exception stack:"s,
"- std::invalid_argument: some argument is invalid"s,
"- std::runtime_error: some_runtime_error"s,
"- std::logic_error: some logic error"s,
"- unknown exception"s
};
#else
std::vector<std::string> expected = {
"exception stack:"s,
"- std::invalid_argument: some argument is invalid"s,
"- std::runtime_error: some_runtime_error"s,
"- std::logic_error: some logic error"s,
"- (anonymous namespace)::some_unknown_error"s
};
#endif

tst::check_eq(actual.size(), expected.size(), SL);

Expand Down

0 comments on commit 28fb9f9

Please sign in to comment.