mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 10:55:57 -04:00
Moved test_error to Catch
This commit is contained in:
parent
9e91418a7a
commit
c2d9aefa15
@ -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})
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user