diff --git a/src/main/java/org/harctoolbox/ircore/IrCoreUtils.java b/src/main/java/org/harctoolbox/ircore/IrCoreUtils.java index 6456067a..76579d47 100644 --- a/src/main/java/org/harctoolbox/ircore/IrCoreUtils.java +++ b/src/main/java/org/harctoolbox/ircore/IrCoreUtils.java @@ -51,6 +51,7 @@ public final class IrCoreUtils { public final static long SOME = -3L; public static final String LINE_SEPARATOR = System.getProperty("line.separator"); + public static final String NEWLINE_REGEX = "\\r?\\n"; private static Map radixPrefixes; private static Map prefixToRadix; diff --git a/src/test/java/org/harctoolbox/irp/IrpTransmogrifierNGTest.java b/src/test/java/org/harctoolbox/irp/IrpTransmogrifierNGTest.java index c1560cfc..30bdd1bd 100644 --- a/src/test/java/org/harctoolbox/irp/IrpTransmogrifierNGTest.java +++ b/src/test/java/org/harctoolbox/irp/IrpTransmogrifierNGTest.java @@ -257,7 +257,7 @@ public void testDecodeNoRepeatedNec() { System.out.println("decodeNoRepeatedNec"); String args = "decode --debug nec1 +9041 -4507 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -44293"; String result = execute(args); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0].substring(0,21), "NEC: {D=12,S=34,F=56}"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0].substring(0,21), "NEC: {D=12,S=34,F=56}"); } @Test(enabled = true) @@ -265,7 +265,7 @@ public void testDecodeRepeatedNec1() { System.out.println("decodeRepeatedNec1"); String args = "decode -p nec1 -r +9041 -4507 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -44293 +9041 -2267 +626 -96193 +9041 -2267 +626 -96193 +9041 -2267 +626 -96193 +9041 -2267 +626 -96193"; String result = execute(args); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "NEC1: {D=12,S=34,F=56}"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "NEC1: {D=12,S=34,F=56}"); } @Test(enabled = true) @@ -273,7 +273,7 @@ public void testDecodeNec1OneDitto() { System.out.println("testDecodeNec1OneDitto"); String args = "decode -p nec1 +9041 -4507 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -1694 +573 -573 +573 -573 +573 -573 +573 -1694 +573 -1694 +573 -44293 +9041 -2267 +626 -96193"; String result = execute(args); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "NEC1: {D=12,S=34,F=56}, beg=0, end=71, reps=1"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "NEC1: {D=12,S=34,F=56}, beg=0, end=71, reps=1"); } @Test(enabled = true) @@ -282,10 +282,10 @@ public void testDecodeNec1OneDittoNec1TwoDittoJunk() { String sequence = NEC1INTRO + " " + NEC1DITTO + " " + NEC1INTRO + " " + NEC1DITTO + " " + NEC1DITTO + "+1234 -54678"; String args = "decode -p nec1 " + sequence; String result = execute(args); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "NEC1: {D=12,S=34,F=56}, beg=0, end=71, reps=1 {UNDECODED. length=78}"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "NEC1: {D=12,S=34,F=56}, beg=0, end=71, reps=1 {UNDECODED. length=78}"); args = "decode -p nec1 --recursive " + sequence; result = execute(args); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "NEC1: {D=12,S=34,F=56}, beg=0, end=71, reps=1 {NEC1: {D=12,S=34,F=56}, beg=72, end=147, reps=2 {UNDECODED. length=2}}"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "NEC1: {D=12,S=34,F=56}, beg=0, end=71, reps=1 {NEC1: {D=12,S=34,F=56}, beg=72, end=147, reps=2 {UNDECODED. length=2}}"); } @Test(enabled = true) @@ -624,56 +624,56 @@ public void testSillyCommand() { public void testHelp() { System.out.println("testHelp"); String result = execute("help"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "Usage: IrpTransmogrifier [options] [command] [command options]"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "Usage: IrpTransmogrifier [options] [command] [command options]"); } @Test(enabled = true) public void testDashHelp() { System.out.println("testDashHelp"); String result = execute("--help"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "Usage: IrpTransmogrifier [options] [command] [command options]"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "Usage: IrpTransmogrifier [options] [command] [command options]"); } @Test(enabled = true) public void testHelpShort() { System.out.println("testHelpShort"); String result = execute("help --short"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "Usage: IrpTransmogrifier [options] [command] [command options]"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "Usage: IrpTransmogrifier [options] [command] [command options]"); } @Test(enabled = true) public void testHelpCommon() { System.out.println("testHelpCommon"); String result = execute("help --common"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "Common options:"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "Common options:"); } @Test(enabled = true) public void testHelpDashHelp() { System.out.println("testHelpDashHelp"); String result = execute("help --help"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "Describe the syntax of program and commands."); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "Describe the syntax of program and commands."); } @Test(enabled = true) public void testHelpDescribe() { System.out.println("testHelpDescribe"); String result = execute("help --describe"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "This command list the syntax for the command(s) given as argument,"); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "This command list the syntax for the command(s) given as argument,"); } @Test(enabled = true) public void testHelpList() { System.out.println("testHelpList"); String result = execute("help list"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "List protocols and their properties."); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "List protocols and their properties."); } @Test(enabled = true) public void testListHelp() { System.out.println("testListHelp"); String result = execute("list --help"); - assertEquals(result.split(IrCoreUtils.LINE_SEPARATOR)[0], "List protocols and their properties."); + assertEquals(result.split(IrCoreUtils.NEWLINE_REGEX)[0], "List protocols and their properties."); } @Test(enabled = true)