PrintfLikeIntegrityChecker extends RegexIntegrityChecker { @Override public void check(String sourceContent, String targetContent) throws PrintfLikeIntegrityCheckerException { try { super.check(sourceContent, targetContent); } catch (RegexCheckerException rce) { throw new PrintfLikeIntegrityCheckerException((rce.getMessage())); } }  @Override String getRegex(); @Override void check(String sourceContent, String targetContent);  }
@Test public void testMacSinglePlaceholderCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %@ files"; String target = "Il y a %@ fichiers"; checker.check(source, target); }
@Test public void testMacMultiplePlaceholdersCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$ld files and %2$@ folders"; String target = "Il y a %1$ld fichiers et %2$@ dossiers"; checker.check(source, target); }
@Test public void testMacPlaceholdersCheckWithRemovedSpacesWorks1() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "%1$@ of %2$@ %3$@"; String target = "%1$@/%2$@%3$@"; checker.check(source, target); }
@Test public void testMacPlaceholdersCheckWithRemovedSpacesWorks2() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "%1$@ %2$@:"; String target = "%1$@%2$@:"; checker.check(source, target); }
@Test public void testMacMultiplePlaceholdersAndTranslationCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$ld files and %2$@ folders"; String target = "%1$ld개 파일과 %2$@개 폴더가 있습니다"; checker.check(source, target); }
@Test public void testMacTranslationAndMultiplePlaceholdersCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "%1$ld files, %2$@ folders"; String target = "파일%1$ld, 폴더%2$@"; checker.check(source, target); }
@Test public void testMacPlaceholderCheckWorksWithDifferentOrder() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$lld files and %2$.2ld folders"; String target = "Il y a %2$.2ld dossiers et %1$lld fichiers"; checker.check(source, target); }
@Test public void testMacPlaceholderCheckFailsIfDifferentPlaceholdersCount() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$04d files and %2$@ folders"; String target = "Il y a %1$04d fichiers"; try { checker.check(source, target); fail("PrintfLikeIntegrityCheckerException must be thrown"); } catch (PrintfLikeIntegrityCheckerException e) { assertEquals(e.getMessage(), "Placeholders in source and target are different"); } }
@Test public void testMacPlaceholderCheckFailsIfSamePlaceholdersCountButSomeRepeatedOrMissing() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$-04d files and %2$@ folders"; String target = "Il y a %1$-04d fichiers et %1$-04d dossiers"; try { checker.check(source, target); fail("PrintfLikeIntegrityCheckerException must be thrown"); } catch (PrintfLikeIntegrityCheckerException e) { assertEquals(e.getMessage(), "Placeholders in source and target are different"); } }
@Test public void testMacPlaceholderCheckFailsIfSamePlaceholdersCountButSpecifierModified() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$.1ld files and %2$.2ld folders"; String target = "Il y a %1$.1ld fichiers et %1$.1ld dossiers"; try { checker.check(source, target); fail("PrintfLikeIntegrityCheckerException must be thrown"); } catch (PrintfLikeIntegrityCheckerException e) { assertEquals(e.getMessage(), "Placeholders in source and target are different"); } }
@Test public void testAndroidSinglePlaceholderCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %d files"; String target = "Il y a %d fichiers"; checker.check(source, target); }
@Test public void testAndroidMultiplePlaceholdersCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$s files and %2$d folders"; String target = "Il y a %1$s fichiers et %2$d dossiers"; checker.check(source, target); }
@Test public void testAndroidMultiplePlaceholdersAndTranslationCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$s files and %2$d folders"; String target = "%1$s개 파일과 %2$d개 폴더가 있습니다"; checker.check(source, target); }
@Test public void testAndroidTranslationAndMultiplePlaceholdersCheckWorks() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "%1$s files, %2$d folders"; String target = "파일%1$s, 폴더%2$d"; checker.check(source, target); }
@Test public void testAndroidPlaceholderCheckWorksWithDifferentOrder() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$d files and %2$d folders"; String target = "Il y a %2$d dossiers et %1$d fichiers"; checker.check(source, target); }
@Test public void testAndroidPlaceholderCheckFailsIfDifferentPlaceholdersCount() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$d files and %2$d folders"; String target = "Il y a %1$d fichiers"; try { checker.check(source, target); fail("PrintfLikeIntegrityCheckerException must be thrown"); } catch (PrintfLikeIntegrityCheckerException e) { assertEquals(e.getMessage(), "Placeholders in source and target are different"); } }
@Test public void testAndroidPlaceholderCheckFailsIfSamePlaceholdersCountButSomeRepeatedOrMissing() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$d files and %2$d folders"; String target = "Il y a %1$d fichiers et %1$d dossiers"; try { checker.check(source, target); fail("PrintfLikeIntegrityCheckerException must be thrown"); } catch (PrintfLikeIntegrityCheckerException e) { assertEquals(e.getMessage(), "Placeholders in source and target are different"); } }
@Test public void testAndroidPlaceholderCheckFailsIfSamePlaceholdersCountButSpecifierModified() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "There are %1$d files and %2$d folders"; String target = "Il y a %1$d fichiers et %2$s dossiers"; try { checker.check(source, target); fail("PrintfLikeIntegrityCheckerException must be thrown"); } catch (PrintfLikeIntegrityCheckerException e) { assertEquals(e.getMessage(), "Placeholders in source and target are different"); } }
@Test public void testSpecifierWithRemovedSpace() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "%1$s of %2$s GB"; String target = "%1$s/%2$sGB"; checker.check(source, target); }
@Test public void testIncorrectlyModifiedSpecifier() throws PrintfLikeIntegrityCheckerException { PrintfLikeIntegrityChecker checker = new PrintfLikeIntegrityChecker(); String source = "%1.1f GB"; String target = "%1,1f Go"; try { checker.check(source, target); fail("PrintfLikeIntegrityCheckerException must be thrown"); } catch (PrintfLikeIntegrityCheckerException e) { assertEquals(e.getMessage(), "Placeholders in source and target are different"); } }