Show
Ignore:
Timestamp:
08/26/08 08:06:55 PM (4 months ago)
Author:
octorian
Message:

Fix for quoted-printable decoding errors (#98)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/LogicMail-1.0/LogicMailTests/src/org/logicprobe/LogicMail/util/StringParserTest.java

    r197 r277  
    649649    /** 
    650650     * Test of decodeQuotedPrintable method, of class org.logicprobe.LogicMail.util.StringParser. 
    651      */ 
    652     public void testDecodeQuotedPrintable() { 
     651     * Basic test. 
     652     */ 
     653    public void testDecodeQuotedPrintable1() { 
    653654        System.out.println("decodeQuotedPrintable"); 
    654655        String text = "=A1Hol=E1 Se=F1or!"; 
     
    659660 
    660661    /** 
     662     * Test of decodeQuotedPrintable method, of class org.logicprobe.LogicMail.util.StringParser. 
     663     * Soft line-break test. 
     664     */ 
     665    public void testDecodeQuotedPrintable2() { 
     666        System.out.println("decodeQuotedPrintable"); 
     667        String text = "=A1Hol=E1 Se=F1or!=20=20H=\n"+ 
     668                      "ow=20are=20you=20today?"; 
     669        String expectedResult = "¡Holá Señor!  How are you today?"; 
     670        String result = StringParser.decodeQuotedPrintable(text); 
     671        assertEquals(expectedResult, result); 
     672    } 
     673 
     674    /** 
    661675     * Test of encodeQuotedPrintable method, of class org.logicprobe.LogicMail.util.StringParser. 
    662      */ 
    663     public void testEncodeQuotedPrintable() { 
     676     * Basic test. 
     677     */ 
     678    public void testEncodeQuotedPrintable1() { 
    664679        System.out.println("encodeQuotedPrintable"); 
    665680        String text = "¡Holá Señor!"; 
    666         String expectedResult = "=A1Hol=E1 Se=F1or!".toLowerCase(); 
    667         String result = StringParser.encodeQuotedPrintable(text).toLowerCase(); 
     681        String expectedResult = "=A1Hol=E1=20Se=F1or!"; 
     682        String result = StringParser.encodeQuotedPrintable(text); 
     683        assertEquals(expectedResult, result); 
     684    } 
     685 
     686    /** 
     687     * Test of encodeQuotedPrintable method, of class org.logicprobe.LogicMail.util.StringParser. 
     688     * Soft line-break test. 
     689     */ 
     690    public void testEncodeQuotedPrintable2() { 
     691        System.out.println("encodeQuotedPrintable"); 
     692        String text = "¡Holá Señor! ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ¡Holá Señor!"; 
     693        String expectedResult = "=A1Hol=E1=20Se=F1or!=20ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=\r\n0123456789=20=A1Hol=E1=20Se=F1or!"; 
     694        String result = StringParser.encodeQuotedPrintable(text); 
    668695        assertEquals(expectedResult, result); 
    669696    } 
     
    723750//                ((StringParserTest)tc).testReadWholeStream(); 
    724751//        }})); 
    725         testSuite.addTest(new StringParserTest("decodeQuotedPrintable", new TestMethod() { 
    726             public void run(TestCase tc) { 
    727                 ((StringParserTest)tc).testDecodeQuotedPrintable(); 
    728         }})); 
    729         testSuite.addTest(new StringParserTest("encodeQuotedPrintable", new TestMethod() { 
    730             public void run(TestCase tc) { 
    731                 ((StringParserTest)tc).testEncodeQuotedPrintable(); 
     752        testSuite.addTest(new StringParserTest("decodeQuotedPrintable1", new TestMethod() { 
     753            public void run(TestCase tc) { 
     754                ((StringParserTest)tc).testDecodeQuotedPrintable1(); 
     755        }})); 
     756        testSuite.addTest(new StringParserTest("decodeQuotedPrintable2", new TestMethod() { 
     757            public void run(TestCase tc) { 
     758                ((StringParserTest)tc).testDecodeQuotedPrintable2(); 
     759        }})); 
     760        testSuite.addTest(new StringParserTest("encodeQuotedPrintable1", new TestMethod() { 
     761            public void run(TestCase tc) { 
     762                ((StringParserTest)tc).testEncodeQuotedPrintable1(); 
     763        }})); 
     764        testSuite.addTest(new StringParserTest("encodeQuotedPrintable2", new TestMethod() { 
     765            public void run(TestCase tc) { 
     766                ((StringParserTest)tc).testEncodeQuotedPrintable2(); 
    732767        }})); 
    733768        return testSuite;