1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. 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 17package tests.api.java.nio.charset; 18 19import dalvik.annotation.TestTargetClass; 20import dalvik.annotation.TestTargets; 21import dalvik.annotation.TestTargetNew; 22import dalvik.annotation.TestLevel; 23 24/** 25 * Test UTF-8 charset. 26 */ 27 28@TestTargetClass(java.nio.charset.Charset.class) 29public class UTF8CharsetTest extends AbstractCharsetTestCase { 30 31 /** 32 * Constructor for UTF8CharsetTest. 33 * 34 */ 35 public UTF8CharsetTest() { 36 super("UTF-8", new String[] { "UTF8" }, true, true); 37 } 38 39 /* 40 * (non-Javadoc) 41 * 42 * @see tests.api.java.nio.charset.ConcreteCharsetTest#testDecode_Normal() 43 */ 44 @TestTargetNew( 45 level = TestLevel.PARTIAL, 46 notes = "Functional test, text source: AbstractCharsetTestCase.internalTestDecode. Exceptions checking missed.", 47 method = "decode", 48 args = {java.nio.ByteBuffer.class} 49 ) 50 public void testDecode_Normal() { 51 byte[] input = new byte[] { 97, 98, -27, -76, -108, -26, -107, -113 }; 52 char[] output = "ab\u5D14\u654F".toCharArray(); 53 internalTestDecode(input, output); 54 } 55 56 /* 57 * (non-Javadoc) 58 * 59 * @see tests.api.java.nio.charset.ConcreteCharsetTest#testEncode_Normal() 60 */ 61 @TestTargetNew( 62 level = TestLevel.PARTIAL, 63 notes = "Functional test, text source: AbstractCharsetTestCase.internalTestEncode. Exceptions checking missed.", 64 method = "encode", 65 args = {java.lang.String.class} 66 ) 67 public void testEncode_Normal() { 68 String input = "ab\u5D14\u654F"; 69 byte[] output = new byte[] { 97, 98, -27, -76, -108, -26, -107, -113 }; 70 internalTestEncode(input, output); 71 } 72} 73