@@ -17,6 +17,7 @@ public class Base64Test {
1717 private byte [] helloWorldTwoLinesAndNewLineBytes ;
1818 private byte [] helloWorldDifferentCharsBytes ;
1919 private byte [] bytes ;
20+ private byte [] allBytes ;
2021
2122 @ Before
2223 public void setUp () throws UnsupportedEncodingException {
@@ -55,6 +56,19 @@ public void setUp() throws UnsupportedEncodingException {
5556 103 , 73 , -30 , 120 , -15 , 104 , -9 , 110 , -24 , -127 , 14 , -57 , -44 , 67 , 9 , 80 , 120 , 42 , 94 , 107 , -81 , -109 , 101 ,
5657 -1 , 91 };
5758
59+ allBytes = new byte []{-128 , -127 , -126 , -125 , -124 , -123 , -122 , -121 , -120 , -119 , -118 , -117 , -116 , -115 , -114 ,
60+ -113 , -112 , -111 , -110 , -109 , -108 , -107 , -106 , -105 , -104 , -103 , -102 , -101 , -100 , -99 , -98 , -97 , -96 , -95 ,
61+ -94 , -93 , -92 , -91 , -90 , -89 , -88 , -87 , -86 , -85 , -84 , -83 , -82 , -81 , -80 , -79 , -78 , -77 , -76 , -75 , -74 ,
62+ -73 , -72 , -71 , -70 , -69 , -68 , -67 , -66 , -65 , -64 , -63 , -62 , -61 , -60 , -59 , -58 , -57 , -56 , -55 , -54 , -53 ,
63+ -52 , -51 , -50 , -49 , -48 , -47 , -46 , -45 , -44 , -43 , -42 , -41 , -40 , -39 , -38 , -37 , -36 , -35 , -34 , -33 , -32 ,
64+ -31 , -30 , -29 , -28 , -27 , -26 , -25 , -24 , -23 , -22 , -21 , -20 , -19 , -18 , -17 , -16 , -15 , -14 , -13 , -12 , -11 ,
65+ -10 , -9 , -8 , -7 , -6 , -5 , -4 , -3 , -2 , -1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 ,
66+ 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 ,
67+ 46 , 47 , 48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , 64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 ,
68+ 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 ,
69+ 100 , 101 , 102 , 103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116 , 117 , 118 , 119 , 120 ,
70+ 121 , 122 , 123 , 124 , 125 , 126 , 127 };
71+
5872 java8Base64 = new Java8Base64 ();
5973 commonsCodecBase64 = new CommonsCodecBase64 ();
6074 jaxbBase64 = new JaxbBase64 ();
@@ -93,32 +107,41 @@ public void testEncode() {
93107 + "wJ3juUsVtujV23SnH43iMggXT7m82STpPGam1hPfmqu2Z0niePFo927ogQ7H1EMJ"
94108 + "UHgqXmuvk2X/Ww==" ;
95109
110+ final String allBytesStr = "gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydnp+goaKjpKWmp6ipqqusra6vsLGys7S1tre4ubq7vL2"
111+ + "+v8DBwsPExcbHyMnKy8zNzs/Q0dLT1NXW19jZ2tvc3d7f4OHi4+Tl5ufo6err7O3u7/Dx8vP09fb3+Pn6+/z9/v8AAQIDBAUGBwg"
112+ + "JCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/QEFCQ0RFRkdISUpLTE1OT1BRUlN"
113+ + "UVVZXWFlaW1xdXl9gYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXp7fH1+fw==" ;
114+
96115 assertEquals (helloWorldEncoded , java8Base64 .internalEncode (helloWorldBytes ));
97116 assertEquals (helloWorldTwoLinesEncoded , java8Base64 .internalEncode (helloWorldTwoLinesBytes ));
98117 assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
99118 java8Base64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
100119 assertEquals (helloWorldDifferentCharsEncoded , java8Base64 .internalEncode (helloWorldDifferentCharsBytes ));
101120 assertEquals (str , java8Base64 .internalEncode (bytes ));
121+ assertEquals (allBytesStr , java8Base64 .internalEncode (allBytes ));
102122
103123 assertEquals (helloWorldEncoded , commonsCodecBase64 .internalEncode (helloWorldBytes ));
104124 assertEquals (helloWorldTwoLinesEncoded , commonsCodecBase64 .internalEncode (helloWorldTwoLinesBytes ));
105125 assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
106126 commonsCodecBase64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
107127 assertEquals (helloWorldDifferentCharsEncoded , commonsCodecBase64 .internalEncode (helloWorldDifferentCharsBytes ));
108128 assertEquals (str , commonsCodecBase64 .internalEncode (bytes ));
129+ assertEquals (allBytesStr , commonsCodecBase64 .internalEncode (allBytes ));
109130
110131 assertEquals (helloWorldEncoded , jaxbBase64 .internalEncode (helloWorldBytes ));
111132 assertEquals (helloWorldTwoLinesEncoded , jaxbBase64 .internalEncode (helloWorldTwoLinesBytes ));
112133 assertEquals (helloWorldTwoLinesAndNewLineEncoded , jaxbBase64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
113134 assertEquals (helloWorldDifferentCharsEncoded , jaxbBase64 .internalEncode (helloWorldDifferentCharsBytes ));
114135 assertEquals (str , jaxbBase64 .internalEncode (bytes ));
136+ assertEquals (allBytesStr , jaxbBase64 .internalEncode (allBytes ));
115137
116138 assertEquals (helloWorldEncoded , jaxb230Base64 .internalEncode (helloWorldBytes ));
117139 assertEquals (helloWorldTwoLinesEncoded , jaxb230Base64 .internalEncode (helloWorldTwoLinesBytes ));
118140 assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
119141 jaxb230Base64 .internalEncode (helloWorldTwoLinesAndNewLineBytes ));
120142 assertEquals (helloWorldDifferentCharsEncoded , jaxb230Base64 .internalEncode (helloWorldDifferentCharsBytes ));
121143 assertEquals (str , jaxb230Base64 .internalEncode (bytes ));
144+ assertEquals (allBytesStr , jaxb230Base64 .internalEncode (allBytes ));
122145 }
123146
124147 @ Test
@@ -145,13 +168,19 @@ public void testEncodeUrlWithoutPadding() {
145168 + "wJ3juUsVtujV23SnH43iMggXT7m82STpPGam1hPfmqu2Z0niePFo927ogQ7H1EMJ"
146169 + "UHgqXmuvk2X_Ww" ;
147170
171+ final String allBytesStr = "gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydnp-goaKjpKWmp6ipqqusra6vsLGys7S1tre4ubq7vL2"
172+ + "-v8DBwsPExcbHyMnKy8zNzs_Q0dLT1NXW19jZ2tvc3d7f4OHi4-Tl5ufo6err7O3u7_Dx8vP09fb3-Pn6-_z9_v8AAQIDBAUGBwg"
173+ + "JCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4_QEFCQ0RFRkdISUpLTE1OT1BRUlN"
174+ + "UVVZXWFlaW1xdXl9gYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXp7fH1-fw" ;
175+
148176 assertEquals (helloWorldEncoded , java8Base64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
149177 assertEquals (helloWorldTwoLinesEncoded , java8Base64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesBytes ));
150178 assertEquals (helloWorldTwoLinesAndNewLineEncoded ,
151179 java8Base64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesAndNewLineBytes ));
152180 assertEquals (helloWorldDifferentCharsEncoded ,
153181 java8Base64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
154182 assertEquals (str , java8Base64 .internalEncodeUrlWithoutPadding (bytes ));
183+ assertEquals (allBytesStr , java8Base64 .internalEncodeUrlWithoutPadding (allBytes ));
155184
156185 assertEquals (helloWorldEncoded , commonsCodecBase64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
157186 assertEquals (helloWorldTwoLinesEncoded ,
@@ -161,6 +190,7 @@ public void testEncodeUrlWithoutPadding() {
161190 assertEquals (helloWorldDifferentCharsEncoded ,
162191 commonsCodecBase64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
163192 assertEquals (str , commonsCodecBase64 .internalEncodeUrlWithoutPadding (bytes ));
193+ assertEquals (allBytesStr , commonsCodecBase64 .internalEncodeUrlWithoutPadding (allBytes ));
164194
165195 assertEquals (helloWorldEncoded , jaxbBase64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
166196 assertEquals (helloWorldTwoLinesEncoded , jaxbBase64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesBytes ));
@@ -169,6 +199,7 @@ public void testEncodeUrlWithoutPadding() {
169199 assertEquals (helloWorldDifferentCharsEncoded ,
170200 jaxbBase64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
171201 assertEquals (str , jaxbBase64 .internalEncodeUrlWithoutPadding (bytes ));
202+ assertEquals (allBytesStr , jaxbBase64 .internalEncodeUrlWithoutPadding (allBytes ));
172203
173204 assertEquals (helloWorldEncoded , jaxb230Base64 .internalEncodeUrlWithoutPadding (helloWorldBytes ));
174205 assertEquals (helloWorldTwoLinesEncoded , jaxb230Base64 .internalEncodeUrlWithoutPadding (helloWorldTwoLinesBytes ));
@@ -177,5 +208,6 @@ public void testEncodeUrlWithoutPadding() {
177208 assertEquals (helloWorldDifferentCharsEncoded ,
178209 jaxb230Base64 .internalEncodeUrlWithoutPadding (helloWorldDifferentCharsBytes ));
179210 assertEquals (str , jaxb230Base64 .internalEncodeUrlWithoutPadding (bytes ));
211+ assertEquals (allBytesStr , jaxb230Base64 .internalEncodeUrlWithoutPadding (allBytes ));
180212 }
181213}
0 commit comments