Automated import from //branches/donutburger/...@142458,142458
This commit is contained in:
parent
7265bb729b
commit
b1d72808d7
@ -374,14 +374,14 @@ public class EncoderUtil {
|
|||||||
sb.append((char) BASE64_TABLE[data >> 18 & 0x3f]);
|
sb.append((char) BASE64_TABLE[data >> 18 & 0x3f]);
|
||||||
sb.append((char) BASE64_TABLE[data >> 12 & 0x3f]);
|
sb.append((char) BASE64_TABLE[data >> 12 & 0x3f]);
|
||||||
sb.append((char) BASE64_TABLE[data >> 6 & 0x3f]);
|
sb.append((char) BASE64_TABLE[data >> 6 & 0x3f]);
|
||||||
sb.append(BASE64_PAD);
|
sb.append((char) BASE64_PAD);
|
||||||
|
|
||||||
} else if (idx == end - 1) {
|
} else if (idx == end - 1) {
|
||||||
int data = (bytes[idx] & 0xff) << 16;
|
int data = (bytes[idx] & 0xff) << 16;
|
||||||
sb.append((char) BASE64_TABLE[data >> 18 & 0x3f]);
|
sb.append((char) BASE64_TABLE[data >> 18 & 0x3f]);
|
||||||
sb.append((char) BASE64_TABLE[data >> 12 & 0x3f]);
|
sb.append((char) BASE64_TABLE[data >> 12 & 0x3f]);
|
||||||
sb.append(BASE64_PAD);
|
sb.append((char) BASE64_PAD);
|
||||||
sb.append(BASE64_PAD);
|
sb.append((char) BASE64_PAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
@ -39,6 +39,14 @@ public class MimeUtilityTest extends TestCase {
|
|||||||
private final String SHORT_UNICODE = "\u2191\u2193\u2190\u2192";
|
private final String SHORT_UNICODE = "\u2191\u2193\u2190\u2192";
|
||||||
private final String SHORT_UNICODE_ENCODED = "=?UTF-8?B?4oaR4oaT4oaQ4oaS?=";
|
private final String SHORT_UNICODE_ENCODED = "=?UTF-8?B?4oaR4oaT4oaQ4oaS?=";
|
||||||
|
|
||||||
|
/** dollar and euro sign */
|
||||||
|
private final String PADDED2_UNICODE = "$\u20AC";
|
||||||
|
private final String PADDED2_UNICODE_ENCODED = "=?UTF-8?B?JOKCrA==?=";
|
||||||
|
private final String PADDED1_UNICODE = "$$\u20AC";
|
||||||
|
private final String PADDED1_UNICODE_ENCODED = "=?UTF-8?B?JCTigqw=?=";
|
||||||
|
private final String PADDED0_UNICODE = "$$$\u20AC";
|
||||||
|
private final String PADDED0_UNICODE_ENCODED = "=?UTF-8?B?JCQk4oKs?=";
|
||||||
|
|
||||||
/** a string without any unicode */
|
/** a string without any unicode */
|
||||||
private final String SHORT_PLAIN = "abcd";
|
private final String SHORT_PLAIN = "abcd";
|
||||||
|
|
||||||
@ -141,6 +149,19 @@ public class MimeUtilityTest extends TestCase {
|
|||||||
assertSame(SHORT_PLAIN, result3);
|
assertSame(SHORT_PLAIN, result3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test about base64 padding variety.
|
||||||
|
*/
|
||||||
|
public void testPaddingOfFoldAndEncode2() {
|
||||||
|
String result1 = MimeUtility.foldAndEncode2(PADDED2_UNICODE, 0);
|
||||||
|
String result2 = MimeUtility.foldAndEncode2(PADDED1_UNICODE, 0);
|
||||||
|
String result3 = MimeUtility.foldAndEncode2(PADDED0_UNICODE, 0);
|
||||||
|
|
||||||
|
assertEquals("padding 2", PADDED2_UNICODE_ENCODED, result1);
|
||||||
|
assertEquals("padding 1", PADDED1_UNICODE_ENCODED, result2);
|
||||||
|
assertEquals("padding 0", PADDED0_UNICODE_ENCODED, result3);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: more tests for foldAndEncode(String s)
|
// TODO: more tests for foldAndEncode(String s)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user