// // Created by Stepan Usatiuk on 13.04.2023. // #include "HelpfulAssertTest.h" std::unique_ptr HelpfulAssertTest::operator()() { auto tg = std::make_unique("HelpfulAssert tests"); tg->addTest(std::make_unique("Equal test", std::function([]() { HelpfulAssert()(1, 1); HelpfulAssert()("hello", "hello"); try { HelpfulAssert()("hello", "hello2"); } catch (const Exception &e) { if (std::string_view(e.what()).find("Expected lhs to compare to hello2\nBut lhs is hello\n") == std::string_view::npos) throw Exception("HelpfulAssert text is wrong"); } catch (...) { throw Exception("HelpfulAssert throws wrong exception"); } try { HelpfulAssert()(1, 2); } catch (const Exception &e) { if (std::string_view(e.what()).find("Expected lhs to compare to 2\nBut lhs is 1\n") == std::string_view::npos) throw Exception("HelpfulAssert text is wrong"); } catch (...) { throw Exception("HelpfulAssert throws wrong exception"); } return true; }))); tg->addTest(std::make_unique("Greater than test", std::function([]() { HelpfulAssert>()(2, 1); try { HelpfulAssert>()(1, 2); } catch (const Exception &e) { if (std::string_view(e.what()).find("Expected lhs to compare to 2\nBut lhs is 1\n") == std::string_view::npos) throw Exception("HelpfulAssert text is wrong"); } catch (...) { throw Exception("HelpfulAssert throws wrong exception"); } return true; }))); tg->addTest(std::make_unique("Less than test", std::function([]() { HelpfulAssert>()(1, 2); try { HelpfulAssert>()(2, 1); } catch (const Exception &e) { if (std::string_view(e.what()).find("Expected lhs to compare to 1\nBut lhs is 2\n") == std::string_view::npos) throw Exception("HelpfulAssert text is wrong"); } catch (...) { throw Exception("HelpfulAssert throws wrong exception"); } return true; }))); return tg; }