From 968d0b2b294a72fc84993449677f8942f85adf2c Mon Sep 17 00:00:00 2001 From: Yury Melnichek Date: Sun, 24 Jul 2011 14:25:22 +0200 Subject: [PATCH] Fix unit tests, broken during Reader refactoring. --- search/search_tests/categories_test.cpp | 3 +-- words/words_tests/sorted_index_test.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/search/search_tests/categories_test.cpp b/search/search_tests/categories_test.cpp index 10e11a87fe..1aaccd40e3 100644 --- a/search/search_tests/categories_test.cpp +++ b/search/search_tests/categories_test.cpp @@ -75,8 +75,7 @@ UNIT_TEST(LoadCategories) p.GetReader("visibility.txt")); search::CategoriesHolder h; - string buffer; - ReaderPtr(p.GetReader(TEST_STRING)).ReadAsString(buffer); + string buffer = TEST_STRING; TEST_GREATER(h.LoadFromStream(buffer), 0, ()); size_t count = 0; Checker f(count); diff --git a/words/words_tests/sorted_index_test.cpp b/words/words_tests/sorted_index_test.cpp index e704776ef1..99b47363a7 100644 --- a/words/words_tests/sorted_index_test.cpp +++ b/words/words_tests/sorted_index_test.cpp @@ -1,6 +1,8 @@ #include "../../testing/testing.hpp" #include "../sloynik_index.hpp" #include "dictionary_mock.hpp" +#include "../../platform/platform.hpp" +#include "../../coding/file_writer.hpp" #include "../../std/algorithm.hpp" #include "../../std/bind.hpp" #include "../../std/map.hpp" @@ -98,7 +100,7 @@ UNIT_TEST(SortedIndex_Smoke) SetupDictionary(dictionary); sl::StrFn strFn = StrFnForTest(); sl::SortedIndex::Build(dictionary, strFn, filePrefix); - sl::SortedIndex idx(dictionary, new FileReader(filePrefix + ".idx"), strFn); + sl::SortedIndex idx(dictionary, GetPlatform().GetReader(filePrefix + ".idx"), strFn); TEST_EQUAL(dictionary.KeyCount(), 5, ()); TEST_EQUAL(KeyByIndexId(idx, 0), "abc", ()); TEST_EQUAL(KeyByIndexId(idx, 1), "He", ()); @@ -120,7 +122,6 @@ UNIT_TEST(SortedIndex_Smoke) TEST_EQUAL(idx.PrefixSearch("Hello"), 2, ()); TEST_EQUAL(idx.PrefixSearch("W"), 4, ()); TEST_EQUAL(idx.PrefixSearch("zzz"), 5, ()); - remove((filePrefix + ".idx").c_str()); - remove((filePrefix + ".idx").c_str()); + FileWriter::DeleteFileX(GetPlatform().WritablePathForFile(filePrefix + ".idx")); TEST(g_AllocatedStrSet.empty(), ()); }