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 */ 16package libcore.java.nio.charset; 17 18import java.nio.ByteBuffer; 19import java.nio.CharBuffer; 20import java.nio.charset.CharacterCodingException; 21import java.nio.charset.CodingErrorAction; 22 23public class OldCharset_MultiByte_EUC_JP extends OldCharset_AbstractTest { 24 @Override protected void setUp() throws Exception { 25 charsetName = "EUC-JP"; 26 testChars = "東京 とうきょう トウキョウ Tokyo 123".toCharArray(); 27 testBytes = theseBytes(0xc5, 0xec, 0xb5, 0xfe, ' ', 28 0xa4, 0xc8, 0xa4, 0xa6, 0xa4, 0xad, 0xa4, 0xe7, 0xa4, 0xa6, ' ', 29 0xa5, 0xc8, 0xa5, 0xa6, 0xa5, 0xad, 0xa5, 0xe7, 0xa5, 0xa6, ' ', 30 'T', 'o', 'k', 'y', 'o', ' ', '1', '2', '3'); 31 super.setUp(); 32 } 33 34 @Override public void test_CodecDynamic() throws CharacterCodingException { 35 encoder.onUnmappableCharacter(CodingErrorAction.REPORT); 36 decoder.onMalformedInput(CodingErrorAction.REPORT); 37 CharBuffer inputCB = CharBuffer.allocate(65536); 38 for (char codePoint = 0; codePoint <= 0xfffe; ++codePoint) { 39 if (encoder.canEncode(codePoint)) { 40 inputCB.put(codePoint); 41 } 42 } 43 inputCB.rewind(); 44 ByteBuffer intermediateBB = encoder.encode(inputCB); 45 inputCB.rewind(); 46 intermediateBB.rewind(); 47 CharBuffer outputCB = decoder.decode(intermediateBB); 48 outputCB.rewind(); 49 assertEqualCBs("decode(encode(A)) must be identical with A!", inputCB, outputCB); 50 } 51} 52