1 /*
2 * Copyright 2005 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 public void testSixBytesChar()
64 {
65 char res = StringUtils.bytesToChar(new byte[]{(byte)0xFD, (byte)0x93, (byte)0x91, (byte)0xBA, (byte)0x95, (byte)0xA3});
66
67 Assert.assertEquals(0x7347A563, res);
68 }
69 */
70 }