1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.codec;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21
22 import java.nio.charset.StandardCharsets;
23
24 import org.junit.jupiter.api.Test;
25
26 /**
27 * Sanity checks for {@link CharEncoding}.
28 */
29 class CharEncodingTest {
30
31 /**
32 * We could make the constructor private in the future, it's a matter a style.
33 */
34 @Test
35 void testConstructor() {
36 new CharEncoding();
37 }
38
39 @Test
40 void testIso8859_1() {
41 assertEquals(StandardCharsets.ISO_8859_1.name(), CharEncoding.ISO_8859_1);
42 }
43
44 @Test
45 void testUsAscii() {
46 assertEquals(StandardCharsets.US_ASCII.name(), CharEncoding.US_ASCII);
47 }
48
49 @Test
50 void testUtf16() {
51 assertEquals(StandardCharsets.UTF_16.name(), CharEncoding.UTF_16);
52 }
53
54 @Test
55 void testUtf16Be() {
56 assertEquals(StandardCharsets.UTF_16BE.name(), CharEncoding.UTF_16BE);
57 }
58
59 @Test
60 void testUtf16Le() {
61 assertEquals(StandardCharsets.UTF_16LE.name(), CharEncoding.UTF_16LE);
62 }
63
64 @Test
65 void testUtf8() {
66 assertEquals(StandardCharsets.UTF_8.name(), CharEncoding.UTF_8);
67 }
68
69 }