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

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

Issue 4477002: Add sanity checks of the BDIC files to ConvertDictTest.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/spellcheck_host.cc ('k') | no next file » | 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 // Create BDICT data and verify it. 108 // Create BDICT data and verify it.
109 hunspell::BDictWriter writer; 109 hunspell::BDictWriter writer;
110 writer.SetComment(aff_reader.comments()); 110 writer.SetComment(aff_reader.comments());
111 writer.SetAffixRules(aff_reader.affix_rules()); 111 writer.SetAffixRules(aff_reader.affix_rules());
112 writer.SetAffixGroups(aff_reader.GetAffixGroups()); 112 writer.SetAffixGroups(aff_reader.GetAffixGroups());
113 writer.SetReplacements(aff_reader.replacements()); 113 writer.SetReplacements(aff_reader.replacements());
114 writer.SetOtherCommands(aff_reader.other_commands()); 114 writer.SetOtherCommands(aff_reader.other_commands());
115 writer.SetWords(dic_reader.words()); 115 writer.SetWords(dic_reader.words());
116 116
117 VerifyWords(dic_reader.words(), writer.GetBDict()); 117 std::string bdict_data = writer.GetBDict();
118 VerifyWords(dic_reader.words(), bdict_data);
119 EXPECT_TRUE(hunspell::BDict::Verify(bdict_data.data(), bdict_data.size()));
120
121 // Trim the end of this BDICT and verify our verifier tells these trimmed
122 // BDICTs are corrupted.
123 for (size_t i = 1; i < bdict_data.size(); ++i) {
124 SCOPED_TRACE(StringPrintf("i = %" PRIuS, i));
125 EXPECT_FALSE(hunspell::BDict::Verify(bdict_data.data(),
126 bdict_data.size() - i));
127 }
118 } 128 }
119 129
120 // Deletes the temporary files. 130 // Deletes the temporary files.
121 // We need to delete them after the above AffReader and DicReader are deleted 131 // We need to delete them after the above AffReader and DicReader are deleted
122 // since they close the input files in their destructors. 132 // since they close the input files in their destructors.
123 file_util::Delete(aff_file, false); 133 file_util::Delete(aff_file, false);
124 file_util::Delete(dic_file, false); 134 file_util::Delete(dic_file, false);
125 } 135 }
126 136
127 } // namespace 137 } // namespace
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 L"\x00f6\x006e\x00f6\x006b", 192 L"\x00f6\x006e\x00f6\x006b",
183 L"\x006d\x0061\x0067\x0075\x006b", 193 L"\x006d\x0061\x0067\x0075\x006b",
184 }; 194 };
185 195
186 std::map<std::wstring, bool> word_list; 196 std::map<std::wstring, bool> word_list;
187 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWords); ++i) 197 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWords); ++i)
188 word_list.insert(std::make_pair<std::wstring, bool>(kWords[i], true)); 198 word_list.insert(std::make_pair<std::wstring, bool>(kWords[i], true));
189 199
190 RunDictionaryTest(kCodepage, word_list); 200 RunDictionaryTest(kCodepage, word_list);
191 } 201 }
OLDNEW
« no previous file with comments | « chrome/browser/spellcheck_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698