Graceful exiting when password is wrong

This commit is contained in:
Sebastian Messmer 2015-10-25 19:00:30 +01:00
parent daa4f0a7f3
commit 4164c2353e
2 changed files with 3 additions and 2 deletions

View File

@ -35,7 +35,7 @@ CryConfigFile CryConfigLoader::_loadConfig(const bf::path &filename) {
auto config = CryConfigFile::load(filename, password);
if (config == none) {
std::cerr << "Could not load config file. Wrong password?" << std::endl;
abort(); // TODO Use exit() once gtest can handle that
exit(1);
}
return std::move(*config);
}

View File

@ -68,8 +68,9 @@ TEST_F(CryConfigLoaderTest, DoesntCrashIfExisting) {
TEST_F(CryConfigLoaderTest, DoesntLoadIfWrongPassword) {
Create("mypassword");
EXPECT_DEATH(
EXPECT_EXIT(
Load("mypassword2"),
::testing::ExitedWithCode(1),
"Wrong password"
);
}