@Test public void testGetter() { Slice sl; sl = new Slice().setLength(12); assertEquals(null, sl.getStart()); assertEquals(null, sl.getStop()); assertEquals(1, sl.getStep()); assertEquals(12, sl.getLength()); sl = new Slice(10).setLength(12); assertEquals(null, sl.getStart()); assertEquals(10, (int) sl.getStop()); assertEquals(1, sl.getStep()); assertEquals(12, sl.getLength()); }
@Test public void testSetter() { Slice sl; sl = new Slice().setLength(12); sl.setStart(1); assertEquals(1, (int) sl.getStart()); sl.setStop(10); assertEquals(10, (int) sl.getStop()); sl.setStep(2); assertEquals(2, sl.getStep()); sl.setLength(11); assertEquals(11, sl.getLength()); sl = new Slice().setLength(12); sl.setStart(3); sl.setStop(10); try { sl.setLength(9); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } try { sl.setStart(11); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } sl = new Slice().setLength(12); sl.setStart(3); sl.setStop(10); try { sl.setLength(9); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } try { sl.setStart(11); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } try { sl.setStop(0); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } sl = new Slice().setLength(12); sl.setStep(-2); sl.setStart(10); sl.setStop(3); try { sl.setLength(9); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } try { sl.setStart(2); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } try { sl.setStop(10); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } try { sl.setStep(0); fail("No exception thrown"); } catch (IllegalArgumentException iae) { // passed } catch (Exception e) { fail("Wrong exception type passed, this should give an IllegalArgumentException"); } sl = new Slice(10).setLength(12); assertEquals(null, sl.getStart()); assertEquals(10, (int) sl.getStop()); assertEquals(1, sl.getStep()); assertEquals(12, sl.getLength()); }