mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-05 11:56:00 -04:00
Moved test_error to Catch
This commit is contained in:
parent
9e91418a7a
commit
c2d9aefa15
@ -1,7 +1,6 @@
|
|||||||
# simple command-line tests
|
# simple command-line tests
|
||||||
SET(CLI_TESTS
|
SET(CLI_TESTS
|
||||||
test_color_constexpr
|
test_color_constexpr
|
||||||
test_error
|
|
||||||
test_optional
|
test_optional
|
||||||
test_pointrect
|
test_pointrect
|
||||||
test_pointrect_constexpr
|
test_pointrect_constexpr
|
||||||
@ -63,6 +62,7 @@ ENDFOREACH(TEST ${TESTS})
|
|||||||
# Catch based tests
|
# Catch based tests
|
||||||
SET(CATCH_CLI_TESTS
|
SET(CATCH_CLI_TESTS
|
||||||
test_color
|
test_color
|
||||||
|
test_error
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(unit_tests_catch catch_main.cc ${CATCH_CLI_TESTS})
|
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 <SDL_error.h>
|
||||||
|
|
||||||
#include <SDL2pp/Exception.hh>
|
#include <SDL2pp/Exception.hh>
|
||||||
|
|
||||||
#include "testing.h"
|
|
||||||
|
|
||||||
using namespace SDL2pp;
|
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");
|
SDL_SetError("BarError");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -15,8 +18,8 @@ BEGIN_TEST(int, char*[])
|
|||||||
} catch (SDL2pp::Exception& e) {
|
} catch (SDL2pp::Exception& e) {
|
||||||
// this SDL_SetError should not clobber Exception contents
|
// this SDL_SetError should not clobber Exception contents
|
||||||
SDL_SetError("AnotherError");
|
SDL_SetError("AnotherError");
|
||||||
EXPECT_EQUAL(e.GetSDLFunction(), "FooFunction");
|
CHECK_THAT(e.GetSDLFunction(), Equals("FooFunction"));
|
||||||
EXPECT_EQUAL(e.GetSDLError(), "BarError");
|
CHECK_THAT(e.GetSDLError(), Equals("BarError"));
|
||||||
EXPECT_EQUAL((std::string)e.what(), "FooFunction failed: BarError");
|
CHECK_THAT(e.what(), Equals("FooFunction failed: BarError"));
|
||||||
}
|
}
|
||||||
END_TEST()
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user