| Index: test/DictionaryTest.cpp |
| =================================================================== |
| --- a/test/DictionaryTest.cpp |
| +++ b/test/DictionaryTest.cpp |
| @@ -43,6 +43,41 @@ |
| } |
| } |
| +namespace |
| +{ |
| + // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx |
| + EXTERN_C IMAGE_DOS_HEADER __ImageBase; |
| +} |
| + |
| +std::wstring GetDllDir() |
| +{ |
| + std::vector<WCHAR> path(MAX_PATH); |
| + DWORD length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], path.size()); |
| + |
| + while (length == path.size()) |
| + { |
| + // Buffer too small, double buffer size |
| + path.resize(path.size() * 2); |
| + length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], path.size()); |
| + } |
| + |
| + try |
| + { |
| + if (length == 0) |
| + throw std::runtime_error("Failed determining module path"); |
| + |
| + std::vector<WCHAR>::reverse_iterator it = std::find(path.rbegin(), path.rend(), L'\\'); |
| + if (it == path.rend()) |
| + throw std::runtime_error("Unexpected plugin path, no backslash found"); |
| + |
| + return std::wstring(path.begin(), it.base()); |
| + } |
| + catch (const std::exception&) |
| + { |
| + return std::wstring(); |
| + } |
| +} |
| + |
| class DictionaryTest : public ::testing::Test |
| { |
| protected: |
| @@ -74,7 +109,7 @@ |
| TEST_F(DictionaryTest, DefaultLocale) |
| { |
| - Dictionary::Create(L"en"); |
| + Dictionary::Create(L"en", basePath); |
| Dictionary* dict = Dictionary::GetInstance(); |
| ASSERT_TRUE(dict); |
| @@ -88,7 +123,7 @@ |
| TEST_F(DictionaryTest, LocaleFallback) |
| { |
| - Dictionary::Create(L"es-ES"); |
| + Dictionary::Create(L"es-ES", basePath); |
| Dictionary* dict = Dictionary::GetInstance(); |
| ASSERT_TRUE(dict); |
| @@ -98,7 +133,7 @@ |
| TEST_F(DictionaryTest, LocaleFallbackShort) |
| { |
| - Dictionary::Create(L"ru-RU"); |
| + Dictionary::Create(L"ru-RU", basePath); |
| Dictionary* dict = Dictionary::GetInstance(); |
| ASSERT_TRUE(dict); |