package junit_example;
import org.junit.*;


/**
  Class for testing thrown exceptions.
  The java.lang.CharSequence class method charAt() is tested.
*/
public class TestThrows {

  static private CharSequence abc = "abc";

  @Test(expected = IndexOutOfBoundsException.class)
  public void charAtNeg1() {
    //  "IndexOutOfBoundsException - if the index argument is negative"
    abc.charAt(-1);
  }

  @Test(expected = IndexOutOfBoundsException.class)
  public void charAtNeg22() {
    //  "IndexOutOfBoundsException - if the index argument is negative"
    abc.charAt(-22);
  }

  @Test(expected = IndexOutOfBoundsException.class)
  public void charAt3() {
    //  "IndexOutOfBoundsException - if the index argument is ...
    //    not less than length()."
    abc.charAt(3);
  }

  @Test(expected = IndexOutOfBoundsException.class)
  public void charAt73() {
    //  "IndexOutOfBoundsException - if the index argument is ...
    //    not less than length()."
    abc.charAt(73);
  }

}
