Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: chrome/tools/convert_dict/convert_dict_unittest.cc

Issue 2929002: Convert some tools to use FilePaths for file names. (Closed)
Patch Set: ok Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/tools/convert_dict/convert_dict.cc ('k') | chrome/tools/convert_dict/dic_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/i18n/icu_string_conversions.h" 10 #include "base/i18n/icu_string_conversions.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 file_util::CreateTemporaryFile(&aff_file); 83 file_util::CreateTemporaryFile(&aff_file);
84 file_util::WriteFile(aff_file, aff_data.c_str(), aff_data.length()); 84 file_util::WriteFile(aff_file, aff_data.c_str(), aff_data.length());
85 85
86 FilePath dic_file; 86 FilePath dic_file;
87 file_util::CreateTemporaryFile(&dic_file); 87 file_util::CreateTemporaryFile(&dic_file);
88 file_util::WriteFile(dic_file, dic_data.c_str(), dic_data.length()); 88 file_util::WriteFile(dic_file, dic_data.c_str(), dic_data.length());
89 89
90 { 90 {
91 // Read the above affix file with AffReader and read the dictionary file 91 // Read the above affix file with AffReader and read the dictionary file
92 // with DicReader, respectively. 92 // with DicReader, respectively.
93 #if defined(OS_WIN) 93 convert_dict::AffReader aff_reader(aff_file);
94 std::string aff_path = WideToUTF8(aff_file.value());
95 std::string dic_path = WideToUTF8(dic_file.value());
96 #else
97 std::string aff_path = aff_file.value();
98 std::string dic_path = dic_file.value();
99 #endif
100 convert_dict::AffReader aff_reader(aff_path);
101 EXPECT_TRUE(aff_reader.Read()); 94 EXPECT_TRUE(aff_reader.Read());
102 95
103 convert_dict::DicReader dic_reader(dic_path); 96 convert_dict::DicReader dic_reader(dic_file);
104 EXPECT_TRUE(dic_reader.Read(&aff_reader)); 97 EXPECT_TRUE(dic_reader.Read(&aff_reader));
105 98
106 // Verify this DicReader includes all the input words. 99 // Verify this DicReader includes all the input words.
107 EXPECT_EQ(word_list.size(), dic_reader.words().size()); 100 EXPECT_EQ(word_list.size(), dic_reader.words().size());
108 for (size_t i = 0; i < dic_reader.words().size(); ++i) { 101 for (size_t i = 0; i < dic_reader.words().size(); ++i) {
109 SCOPED_TRACE(StringPrintf("dic_reader.words()[%" PRIuS "]: %s", 102 SCOPED_TRACE(StringPrintf("dic_reader.words()[%" PRIuS "]: %s",
110 i, dic_reader.words()[i].first.c_str())); 103 i, dic_reader.words()[i].first.c_str()));
111 std::wstring word(UTF8ToWide(dic_reader.words()[i].first)); 104 std::wstring word(UTF8ToWide(dic_reader.words()[i].first));
112 EXPECT_TRUE(word_list.find(word) != word_list.end()); 105 EXPECT_TRUE(word_list.find(word) != word_list.end());
113 } 106 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 L"\x00f6\x006e\x00f6\x006b", 182 L"\x00f6\x006e\x00f6\x006b",
190 L"\x006d\x0061\x0067\x0075\x006b", 183 L"\x006d\x0061\x0067\x0075\x006b",
191 }; 184 };
192 185
193 std::map<std::wstring, bool> word_list; 186 std::map<std::wstring, bool> word_list;
194 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWords); ++i) 187 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWords); ++i)
195 word_list.insert(std::make_pair<std::wstring, bool>(kWords[i], true)); 188 word_list.insert(std::make_pair<std::wstring, bool>(kWords[i], true));
196 189
197 RunDictionaryTest(kCodepage, word_list); 190 RunDictionaryTest(kCodepage, word_list);
198 } 191 }
OLDNEW
« no previous file with comments | « chrome/tools/convert_dict/convert_dict.cc ('k') | chrome/tools/convert_dict/dic_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698