@@ -128,6 +128,7 @@ private static void checkFile(@Nonnull final String baseFileName) throws Excepti
128128 LOG .debug ("checkFile: lat/lon = {}" , reference .point );
129129 LOG .debug ("checkFile: expected = #{}: {}" , reference .mapcodes .size (), GSON .toJson (reference .mapcodes ));
130130 }
131+ ++i ;
131132
132133 // Encode lat/lon to series of mapcodes and check the resulting mapcodes.
133134 final List <Mapcode > results = MapcodeCodec .encode (
@@ -172,53 +173,43 @@ private static void checkFile(@Nonnull final String baseFileName) throws Excepti
172173 }
173174
174175 // For every mapcode in the result set, check if it is contained in the reference set.
176+ int precision = 0 ;
175177 for (final Mapcode result : results ) {
176178 boolean found = false ;
177179 for (final MapcodeRec referenceMapcodeRec : reference .mapcodes ) {
180+ precision = (referenceMapcodeRec .mapcode .lastIndexOf ('-' ) > 4 ) ? 2 : 0 ;
181+
178182 if (referenceMapcodeRec .territory .equals (result .getTerritory ())) {
179- if (referenceMapcodeRec .mapcode .lastIndexOf ('-' ) > 4 ) {
180- if (referenceMapcodeRec .mapcode .equals (result .getCode (2 ))) {
181- found = true ;
182- break ;
183- }
184- } else {
185- if (referenceMapcodeRec .mapcode .equals (result .getCode ())) {
186- found = true ;
187- break ;
188- }
183+ if (referenceMapcodeRec .mapcode .equals (result .getCode (precision ))) {
184+ found = true ;
185+ break ;
189186 }
190187 }
191188 }
192189 if (!found ) {
193190
194191 // This does not fail the test, but rather produces an ERROR in the log file.
195192 // It indicates a discrepancy in the C and Java implementations.
196- LOG .error ("checkFile: Mapcode '{}' at {} is not in the reference file!" ,
197- result , reference .point );
193+ LOG .error ("checkFile: Created '{}' at {} which is not present in the reference file!\n ref={} \n result={} " ,
194+ result . getCode ( precision ) , reference .point , GSON . toJson ( reference ), GSON . toJson ( result ) );
198195 ++error ;
199196 }
200197 }
201198
202199 // For every Mapcode in the reference set, check if it is contained in the result set.
203200 for (final MapcodeRec referenceMapcodeRec : reference .mapcodes ) {
201+ precision = (referenceMapcodeRec .mapcode .lastIndexOf ('-' ) > 4 ) ? 2 : 0 ;
204202 boolean found = false ;
205203 for (final Mapcode result : results ) {
206204 if (referenceMapcodeRec .territory .equals (result .getTerritory ())) {
207- if (referenceMapcodeRec .mapcode .lastIndexOf ('-' ) > 4 ) {
208- if (referenceMapcodeRec .mapcode .equals (result .getCode (2 ))) {
209- found = true ;
210- break ;
211- }
212- } else {
213- if (referenceMapcodeRec .mapcode .equals (result .getCode ())) {
214- found = true ;
215- break ;
216- }
205+ if (referenceMapcodeRec .mapcode .equals (result .getCode (precision ))) {
206+ found = true ;
207+ break ;
217208 }
218209 }
219210 }
220211 if (!found ) {
221- LOG .error ("checkFile: Mapcode '{} {}' at {} is not produced by the decoder!" ,
212+ LOG .error ("checkFile: Found '{} {}' at {} in reference file, not produced by new decoder!" ,
222213 referenceMapcodeRec .territory , referenceMapcodeRec .mapcode , reference .point );
223214 ++error ;
224215 }
@@ -246,11 +237,6 @@ private static void checkFile(@Nonnull final String baseFileName) throws Excepti
246237 ++error ;
247238 }
248239 }
249-
250- if (showLogLine ) {
251- LOG .debug ("" );
252- }
253- ++i ;
254240 }
255241 } catch (final EOFException e ) {
256242 // OK.
0 commit comments