Moved test_error to Catch

This commit is contained in:
Vraiment 2017-07-22 19:02:30 -07:00
parent 9e91418a7a
commit c2d9aefa15
2 changed files with 12 additions and 9 deletions

View File

@ -1,7 +1,6 @@
# simple command-line tests
SET(CLI_TESTS
test_color_constexpr
test_error
test_optional
test_pointrect
test_pointrect_constexpr
@ -63,6 +62,7 @@ ENDFOREACH(TEST ${TESTS})
# Catch based tests
SET(CATCH_CLI_TESTS
test_color
test_error
)
ADD_EXECUTABLE(unit_tests_catch catch_main.cc ${CATCH_CLI_TESTS})

View File

@ -1,13 +1,16 @@
#include <SDL_main.h>
#include "catch.hpp"
#include <SDL_error.h>
#include <SDL2pp/Exception.hh>
#include "testing.h"
using namespace SDL2pp;
BEGIN_TEST(int, char*[])
using Catch::Equals;
auto const TAGS = "[general][error]";
TEST_CASE("Test throwing Exception class", TAGS) {
SDL_SetError("BarError");
try {
@ -15,8 +18,8 @@ BEGIN_TEST(int, char*[])
} catch (SDL2pp::Exception& e) {
// this SDL_SetError should not clobber Exception contents
SDL_SetError("AnotherError");
EXPECT_EQUAL(e.GetSDLFunction(), "FooFunction");
EXPECT_EQUAL(e.GetSDLError(), "BarError");
EXPECT_EQUAL((std::string)e.what(), "FooFunction failed: BarError");
CHECK_THAT(e.GetSDLFunction(), Equals("FooFunction"));
CHECK_THAT(e.GetSDLError(), Equals("BarError"));
CHECK_THAT(e.what(), Equals("FooFunction failed: BarError"));
}
END_TEST()
}