@@ -51,7 +51,7 @@ class DCTTestHelper final {
5151 static uint32_t GetStateIdForPrefix (const fsa::automata_t & fsa, const std::string& query) {
5252 uint32_t state = fsa->GetStartState ();
5353 size_t depth = 0 ;
54- size_t query_length = query.size ();
54+ const size_t query_length = query.size ();
5555
5656 while (state != 0 && depth != query_length) {
5757 state = fsa->TryWalkTransition (state, query[depth]);
@@ -62,13 +62,13 @@ class DCTTestHelper final {
6262 }
6363};
6464
65- typedef boost::mpl::list<keyvi::dictionary::DictionaryCompiler< dictionary_type_t ::INT_WITH_WEIGHTS>,
66- keyvi::dictionary::DictionaryIndexCompiler <dictionary_type_t ::INT_WITH_WEIGHTS>>
67- int_with_weight_types ;
65+ using int_with_weight_types =
66+ boost::mpl::list< keyvi::dictionary::DictionaryCompiler <dictionary_type_t ::INT_WITH_WEIGHTS>,
67+ keyvi::dictionary::DictionaryIndexCompiler< dictionary_type_t ::INT_WITH_WEIGHTS>> ;
6868
6969BOOST_AUTO_TEST_CASE_TEMPLATE (minimizationIntInnerWeights, DictT, int_with_weight_types) {
7070 // simulating permutation
71- std::vector<std::pair<std::string, uint32_t >> test_data = {
71+ const std::vector<std::pair<std::string, uint32_t >> test_data = {
7272 {" fb#fb msg downl de" , 22 }, {" msg#fb msg downl de" , 22 }, {" downl#fb msg downl de" , 22 },
7373 {" de#fb msg downl de" , 22 }, {" fb msg#fb msg downl de" , 22 }, {" fb downl#fb msg downl de" , 22 },
7474 {" fb de#fb msg downl de" , 22 }, {" msg fb#fb msg downl de" , 22 }, {" msg downl#fb msg downl de" , 22 },
@@ -79,62 +79,63 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(minimizationIntInnerWeights, DictT, int_with_weigh
7979
8080 DictT compiler (keyvi::util::parameters_t ({{" memory_limit_mb" , " 10" }}));
8181
82- for (auto p : test_data) {
82+ for (const auto & p : test_data) {
8383 compiler.Add (p.first , p.second );
8484 }
8585 compiler.Compile ();
8686
8787 boost::filesystem::path temp_path = boost::filesystem::temp_directory_path ();
8888
8989 temp_path /= boost::filesystem::unique_path (" dictionary-unit-test-dictionarycompiler-%%%%-%%%%-%%%%-%%%%" );
90- std::string file_name = temp_path.string ();
90+ const std::string file_name = temp_path.string ();
9191
9292 compiler.WriteToFile (file_name);
9393
94- Dictionary d (file_name. c_str () );
95- fsa::automata_t a = d.GetFsa ();
94+ const Dictionary d (file_name);
95+ const fsa::automata_t a = d.GetFsa ();
9696
97- std::string reference_value (" de#" );
98- uint32_t reference_weight = DCTTestHelper::GetStateIdForPrefix (a, reference_value);
97+ const std::string reference_value (" de#" );
98+ const uint32_t reference_weight = DCTTestHelper::GetStateIdForPrefix (a, reference_value);
9999
100- std::vector<std::string> query_data = {" fb#" , " msg#" , " downl#" , " fb msg#" , " fb downl#" , " downl fb#" , " downl de#" };
100+ const std::vector<std::string> query_data = {" fb#" , " msg#" , " downl#" , " fb msg#" ,
101+ " fb downl#" , " downl fb#" , " downl de#" };
101102
102103 size_t tested_values = 0 ;
103- for (auto q : query_data) {
104+ for (const auto & q : query_data) {
104105 BOOST_CHECK (reference_weight == DCTTestHelper::GetStateIdForPrefix (a, q));
105106 ++tested_values;
106107 }
107108
108109 BOOST_CHECK (tested_values == query_data.size ());
109- std::remove (file_name.c_str ());
110+ BOOST_CHECK ( std::remove (file_name.c_str ()) == 0 );
110111}
111112
112113BOOST_AUTO_TEST_CASE_TEMPLATE (unsortedKeys, DictT, int_with_weight_types) {
113114 // simulating permutation
114- std::vector<std::pair<std::string, uint32_t >> test_data = {
115+ const std::vector<std::pair<std::string, uint32_t >> test_data = {
115116 {" uboot" , 22 }, {" überfall" , 33 }, {" vielleicht" , 43 }, {" arbeit" , 3 }, {" zoo" , 5 }, {" ändern" , 6 },
116117 };
117118
118119 DictT compiler (keyvi::util::parameters_t ({{" memory_limit_mb" , " 10" }}));
119120
120- for (auto p : test_data) {
121+ for (const auto & p : test_data) {
121122 compiler.Add (p.first , p.second );
122123 }
123124 compiler.Compile ();
124125
125126 boost::filesystem::path temp_path = boost::filesystem::temp_directory_path ();
126127
127128 temp_path /= boost::filesystem::unique_path (" dictionary-unit-test-dictionarycompiler-%%%%-%%%%-%%%%-%%%%" );
128- std::string file_name = temp_path.string ();
129+ const std::string file_name = temp_path.string ();
129130
130131 compiler.WriteToFile (file_name);
131132
132- Dictionary d (file_name. c_str () );
133+ const Dictionary d (file_name);
133134
134- fsa::automata_t f (d.GetFsa ());
135+ const fsa::automata_t f (d.GetFsa ());
135136
136137 fsa::EntryIterator it (f);
137- fsa::EntryIterator end_it;
138+ const fsa::EntryIterator end_it;
138139
139140 std::stringstream ss;
140141
@@ -181,35 +182,35 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(unsortedKeys, DictT, int_with_weight_types) {
181182 ++it;
182183 BOOST_CHECK (it == end_it);
183184
184- std::remove (file_name.c_str ());
185+ BOOST_CHECK ( std::remove (file_name.c_str ()) == 0 );
185186}
186187
187188BOOST_AUTO_TEST_CASE_TEMPLATE (compactSize, DictT, int_with_weight_types) {
188189 // simulating permutation
189- std::vector<std::pair<std::string, uint32_t >> test_data = {
190+ const std::vector<std::pair<std::string, uint32_t >> test_data = {
190191 {" uboot" , 22 }, {" überfall" , 33 }, {" vielleicht" , 43 }, {" arbeit" , 3 }, {" zoo" , 5 }, {" ändern" , 6 },
191192 };
192193
193194 DictT compiler (keyvi::util::parameters_t ({{" memory_limit_mb" , " 10" }}));
194195
195- for (auto p : test_data) {
196+ for (const auto & p : test_data) {
196197 compiler.Add (p.first , p.second );
197198 }
198199 compiler.Compile ();
199200
200201 boost::filesystem::path temp_path = boost::filesystem::temp_directory_path ();
201202
202203 temp_path /= boost::filesystem::unique_path (" dictionary-unit-test-dictionarycompiler-%%%%-%%%%-%%%%-%%%%" );
203- std::string file_name = temp_path.string ();
204+ const std::string file_name = temp_path.string ();
204205
205206 compiler.WriteToFile (file_name);
206207
207- Dictionary d (file_name. c_str () );
208+ const Dictionary d (file_name);
208209
209- fsa::automata_t f (d.GetFsa ());
210+ const fsa::automata_t f (d.GetFsa ());
210211
211212 fsa::EntryIterator it (f);
212- fsa::EntryIterator end_it;
213+ const fsa::EntryIterator end_it;
213214
214215 BOOST_CHECK_EQUAL (" arbeit" , it.GetKey ());
215216 ++it;
@@ -225,12 +226,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(compactSize, DictT, int_with_weight_types) {
225226 ++it;
226227 BOOST_CHECK (it == end_it);
227228
228- std::remove (file_name.c_str ());
229+ BOOST_CHECK ( std::remove (file_name.c_str ()) == 0 );
229230}
230231
231- typedef boost::mpl::list<keyvi::dictionary::DictionaryCompiler<dictionary_type_t ::JSON>,
232- keyvi::dictionary::DictionaryIndexCompiler<dictionary_type_t ::JSON>>
233- json_types;
232+ using json_types = boost::mpl::list<keyvi::dictionary::DictionaryCompiler<dictionary_type_t ::JSON>,
233+ keyvi::dictionary::DictionaryIndexCompiler<dictionary_type_t ::JSON>>;
234234
235235BOOST_AUTO_TEST_CASE_TEMPLATE (MultipleKeyUpdateAndCompile, DictT, json_types) {
236236 DictT compiler (keyvi::util::parameters_t ({{" memory_limit_mb" , " 10" }}));
@@ -251,14 +251,14 @@ void bigger_compile_test(const keyvi::util::parameters_t& params = keyvi::util::
251251
252252 boost::filesystem::path temp_path = boost::filesystem::temp_directory_path ();
253253 temp_path /= boost::filesystem::unique_path (" dictionary-unit-test-dictionarycompiler-%%%%-%%%%-%%%%-%%%%" );
254- std::string file_name = temp_path.string ();
254+ const std::string file_name = temp_path.string ();
255255
256256 compiler.WriteToFile (file_name);
257257
258- Dictionary d (file_name. c_str () );
258+ const Dictionary d (file_name);
259259
260260 for (size_t i = 0 ; i < keys; ++i) {
261- keyvi::dictionary::match_t m = d[" loooooooooooooooonnnnnnnngggggggg_key-" + std::to_string (i)];
261+ const keyvi::dictionary::match_t m = d[" loooooooooooooooonnnnnnnngggggggg_key-" + std::to_string (i)];
262262 BOOST_CHECK_EQUAL (" loooooooooooooooonnnnnnnngggggggg_key-" + std::to_string (i), m->GetMatchedString ());
263263 BOOST_CHECK_EQUAL (" {\" id\" :" + std::to_string (i) + " }" , m->GetValueAsString ());
264264 }
@@ -286,25 +286,25 @@ BOOST_AUTO_TEST_CASE(float_dictionary) {
286286 boost::filesystem::path temp_path = boost::filesystem::temp_directory_path ();
287287
288288 temp_path /= boost::filesystem::unique_path (" dictionary-unit-test-dictionarycompiler-%%%%-%%%%-%%%%-%%%%" );
289- std::string file_name = temp_path.string ();
289+ const std::string file_name = temp_path.string ();
290290
291291 compiler.WriteToFile (file_name);
292292
293- Dictionary d (file_name. c_str () );
293+ const Dictionary d (file_name);
294294
295295 bool matched = false ;
296- for (auto m : d.Get (" abbe" )) {
296+ for (const auto & m : d.Get (" abbe" )) {
297297 BOOST_CHECK_EQUAL (" 3.1, 0.2, 1.3, 0.4, 0.5" , m->GetValueAsString ());
298298 std::vector<float > float_vector = keyvi::util::DecodeFloatVector (m->GetRawValueAsString ());
299299 BOOST_CHECK_EQUAL (5 , float_vector.size ());
300- BOOST_CHECK_EQUAL (3 .1f , float_vector[0 ]);
301- BOOST_CHECK_EQUAL (1 .3f , float_vector[2 ]);
302- BOOST_CHECK_EQUAL (0 .5f , float_vector[4 ]);
300+ BOOST_CHECK_EQUAL (3 .1F , float_vector[0 ]);
301+ BOOST_CHECK_EQUAL (1 .3F , float_vector[2 ]);
302+ BOOST_CHECK_EQUAL (0 .5F , float_vector[4 ]);
303303 matched = true ;
304304 }
305305 BOOST_CHECK (matched);
306306
307- std::remove (file_name.c_str ());
307+ BOOST_CHECK ( std::remove (file_name.c_str ()) == 0 );
308308}
309309
310310BOOST_AUTO_TEST_CASE_TEMPLATE (MultipleCompile, DictT, json_types) {
0 commit comments