1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.asn1new.util;
18
19 import junit.framework.Assert;
20 import junit.framework.TestCase;
21
22 /***
23 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
24 */
25 public class StringUtilsTest extends TestCase {
26
27 public void testOneByteChar()
28 {
29 char res = StringUtils.bytesToChar(new byte[]{0x30});
30
31 Assert.assertEquals('0', res);
32 }
33
34 public void testOneByteChar00()
35 {
36 char res = StringUtils.bytesToChar(new byte[]{0x00});
37
38 Assert.assertEquals(0x00, res);
39 }
40
41 public void testOneByteChar7F()
42 {
43 char res = StringUtils.bytesToChar(new byte[]{0x7F});
44
45 Assert.assertEquals(0x7F, res);
46 }
47
48 public void testTwoBytesChar()
49 {
50 char res = StringUtils.bytesToChar(new byte[]{(byte)0xCE, (byte)0x91});
51
52 Assert.assertEquals(0x0391, res);
53 }
54
55 public void testThreeBytesChar()
56 {
57 char res = StringUtils.bytesToChar(new byte[]{(byte)0xE2, (byte)0x89, (byte)0xA2});
58
59 Assert.assertEquals(0x2262, res);
60 }
61
62
63
64
65
66
67
68
69
70 }