mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
newly added a test testDecodeEncodedWords()
This commit is contained in:
parent
f93bade5df
commit
1c7d7af975
113
tests/src/com/fsck/k9/mail/internet/DecoderUtilTest.java
Normal file
113
tests/src/com/fsck/k9/mail/internet/DecoderUtilTest.java
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
package com.fsck.k9.mail.internet;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class DecoderUtilTest extends TestCase {
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDecodeEncodedWords() {
|
||||||
|
String body, expect;
|
||||||
|
MimeMessage message;
|
||||||
|
|
||||||
|
body = "abc";
|
||||||
|
expect = "abc";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?us-ascii?q?abc?=";
|
||||||
|
expect = "abc";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?";
|
||||||
|
expect = "=?";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=??";
|
||||||
|
expect = "=??";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=???";
|
||||||
|
expect = "=???";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=????";
|
||||||
|
expect = "=????";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=????=";
|
||||||
|
expect = "=????=";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=??q??=";
|
||||||
|
expect = "=??q??=";;
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=??q?a?=";
|
||||||
|
expect = "=??q?a?=";
|
||||||
|
//expect = "a";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=??=";
|
||||||
|
expect = "=??=";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?x?=";
|
||||||
|
expect = "=?x?=";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?x??=";
|
||||||
|
expect = "=?x??=";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?x?q?=";
|
||||||
|
expect = "=?x?q?=";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?x?q??=";
|
||||||
|
expect = "=?x?q??=";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?x?q?X?=";
|
||||||
|
expect = "=?x?q?X?=";
|
||||||
|
//expect = "X";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
// invalid base64 string
|
||||||
|
body = "=?us-ascii?b?abc?=";
|
||||||
|
expect = "";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
// broken encoded header
|
||||||
|
body = "=?us-ascii?q?abc?= =?";
|
||||||
|
expect = "abc =?";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
body = "=?x?= =?";
|
||||||
|
expect = "=?x?= =?";
|
||||||
|
message = null;
|
||||||
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user