From debabff7787a994479a0b9c922cf090f3face84f Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 7 Jul 2021 16:06:48 +0200 Subject: [PATCH] Test: PityTest - add test_assert.cc --- test/pitytest11/test/test_assert.cc | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/pitytest11/test/test_assert.cc diff --git a/test/pitytest11/test/test_assert.cc b/test/pitytest11/test/test_assert.cc new file mode 100644 index 0000000..b9f9c52 --- /dev/null +++ b/test/pitytest11/test/test_assert.cc @@ -0,0 +1,35 @@ +#include "../src/PityTest.hh" +#include +#include + +using namespace pEp::PityTest11; + +using TestUnit = PityUnit<>; + +void not_throwing() {} + +void throwing() +{ + throw std::runtime_error{ "Fsd" }; +} + +int main(int argc, char* argv[]) +{ + TestUnit asserts {"test_asserts"}; + asserts.add("nfdsg", []() { + PITYASSERT(true, "thats wrong"); + try { + PITYASSERT(false, "thats correct"); + throw std::runtime_error("PITYASSERT(false) does not throw"); + } catch (const PityAssertException& pae) { + } + }) + + + PITYASSERT_THROWS(throwing(), "is actually throwing "); + try { + PITYASSERT_THROWS(not_throwing(), "is actually not throwing"); + throw std::runtime_error("PITYASSERT(false) does not throw"); + } catch (const PityAssertException& pae) { + } +}