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 * http://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 18package libcore.java.io; 19 20import java.io.IOException; 21import java.io.StringReader; 22 23public class OldStringReaderTest extends junit.framework.TestCase { 24 25 String testString = "This is a test string"; 26 27 StringReader sr; 28 29 public void test_markI() throws IOException { 30 sr = new StringReader(testString); 31 try { 32 sr.mark(-1); 33 fail("IllegalArgumentException not thrown!"); 34 } catch (IllegalArgumentException e) { 35 } 36 } 37 38 public void test_read$CII() throws Exception { 39 char[] buf = new char[testString.length()]; 40 sr = new StringReader(testString); 41 try { 42 sr.read(buf, 0, -1); 43 fail("IndexOutOfBoundsException was not thrown"); 44 } catch (IndexOutOfBoundsException e) { 45 // Expected 46 } 47 try { 48 sr.read(buf, -1, 1); 49 fail("IndexOutOfBoundsException was not thrown"); 50 } catch (IndexOutOfBoundsException e) { 51 // Expected 52 } 53 try { 54 sr.read(buf, 1, testString.length()); 55 fail("IndexOutOfBoundsException was not thrown"); 56 } catch (IndexOutOfBoundsException e) { 57 // Expected 58 } 59 } 60 61 protected void tearDown() { 62 63 try { 64 sr.close(); 65 } catch (Exception e) { 66 } 67 } 68} 69