libSDL2pp/tests/test_error.cc
2016-01-18 23:19:47 +03:00

23 lines
537 B
C++

#include <SDL2/SDL_main.h>
#include <SDL2/SDL_error.h>
#include <SDL2pp/Exception.hh>
#include "testing.h"
using namespace SDL2pp;
BEGIN_TEST(int, char*[])
SDL_SetError("BarError");
try {
throw Exception("FooFunction");
} 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");
}
END_TEST()