Properly fix "bad cast" exceptions in tests.

The exceptions were originating from boost::locale::to_lower, when the
global locale had not been set correctly.
This commit is contained in:
Oliver Hamlet
2015-07-14 22:16:23 +01:00
parent f5204d3e0d
commit 5e908ec5b6
3 changed files with 10 additions and 23 deletions
+1 -12
View File
@@ -28,18 +28,7 @@ along with LOOT. If not, see
#include "backend/masterlist.h"
#include "tests/fixtures.h"
class Masterlist : public SkyrimTest {
protected:
inline virtual void SetUp() {
SkyrimTest::SetUp();
// 'bad cast' exceptions are thrown for some reason unless a game is
// initialised.
loot::Game game(loot::Game::tes5);
game.SetGamePath(dataPath.parent_path());
ASSERT_NO_THROW(game.Init(false, localPath));
}
};
class Masterlist : public SkyrimTest {};
TEST_F(Masterlist, Update_Game) {
loot::Game game(loot::Game::tes5);
+5 -11
View File
@@ -32,23 +32,17 @@ class MetadataList : public SkyrimTest {
protected:
MetadataList() :
metadataPath("./testing-metadata-master/masterlist.yaml"),
savedMetadataPath("./testing-metadata-master/saved.masterlist.yaml") {}
savedMetadataPath("./testing-metadata-master/saved.masterlist.yaml") {
PluginMetadataToString = [](const loot::PluginMetadata& plugin) {
return plugin.Name();
};
}
inline virtual void SetUp() {
SkyrimTest::SetUp();
ASSERT_TRUE(boost::filesystem::exists(metadataPath));
ASSERT_FALSE(boost::filesystem::exists(savedMetadataPath));
// 'bad cast' exceptions are thrown for some reason unless a game is
// initialised.
loot::Game game(loot::Game::tes5);
game.SetGamePath(dataPath.parent_path());
ASSERT_NO_THROW(game.Init(false, localPath));
PluginMetadataToString = [](const loot::PluginMetadata& plugin) {
return plugin.Name();
};
}
inline virtual void TearDown() {
+4
View File
@@ -73,6 +73,10 @@ TEST(ModuloOperator, Cpp11Conformance) {
}
int main(int argc, char **argv) {
//Set the locale to get encoding conversions working correctly.
std::locale::global(boost::locale::generator().generate(""));
boost::filesystem::path::imbue(std::locale());
//Disable logging or else stdout will get overrun.
boost::log::core::get()->set_logging_enabled(false);