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 org.apache.harmony.tests.java.nio.charset; 18 19import java.io.UnsupportedEncodingException; 20import java.nio.ByteBuffer; 21import java.nio.charset.Charset; 22 23/** 24 * test utf-8 decoder 25 */ 26public class UTFCharsetDecoderTest extends CharsetDecoderTest { 27 28 protected void setUp() throws Exception { 29 cs = Charset.forName("utf-8"); 30 super.setUp(); 31 } 32 33 /* 34 * @see CharsetDecoderTest#tearDown() 35 */ 36 protected void tearDown() throws Exception { 37 super.tearDown(); 38 } 39 40 // FIXME: give up this tests 41 // public void testDefaultCharsPerByte(){ 42 // assertEquals(decoder.averageCharsPerByte(), 0.333, 0.001); 43 // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); 44 // // assertEquals(1, decoder.averageCharsPerByte()); 45 // // assertEquals(1, decoder.maxCharsPerByte()); 46 // } 47 48 ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException { 49 return null; 50 } 51 52 ByteBuffer getMalformedByteBuffer() throws UnsupportedEncodingException { 53 ByteBuffer buffer = ByteBuffer.allocate(getByteBuffer().remaining() + 1); 54 buffer.put((byte) 0xd8); 55 buffer.put(getByteBuffer()); 56 buffer.flip(); 57 return buffer; 58 } 59 60 ByteBuffer getExceptionByteArray() throws UnsupportedEncodingException { 61 return null; 62 } 63 64 protected String getString() { 65 return " buffer \u041c\u0430\u0441\u044e\u043b\u044f \u611b"; 66 } 67 68 protected ByteBuffer getByteBuffer() { 69 return ByteBuffer.wrap(new byte[] { 32, 98, 117, 102, 102, 101, 114, 70 32, (byte) 0xd0, (byte) 0x9c, (byte) 0xd0, (byte) 0xb0, 71 (byte) 0xd1, (byte) 0x81, (byte) 0xd1, (byte) 0x8e, 72 (byte) 0xd0, (byte) 0xbb, (byte) 0xd1, (byte) 0x8f, 32, 73 (byte) 0xe6, (byte) 0x84, (byte) 0x9b }); 74 } 75 76} 77