}
}
@Test
public void testPipeColoring() throws Exception {
Pipe pipe = new PipeImpl( new ImmutableSegment2D( 0, 0, 0, 10 ) );
assertFalse( pipe.isColored() );
pipe.setColored( new Point( 0, 1 ), true );
assertFalse( pipe.isColored() );
assertTrue( pipe.isColoredAt( new Point( 0, 1 ) ) );
for (int i = 1; i < 4; i++) {
pipe.setColored( new Point( 0, i ), true );
}
try {
pipe.setColored( new Point( 88, 55 ), true );
fail();
} catch ( IllegalArgumentException e ) {
}
try {
pipe.setColored( new Point( 0, 0 ), true );
fail();
} catch ( IllegalArgumentException e ) {
}
try {
pipe.setColored( new Point( 0, 10 ), true );
fail();
} catch ( IllegalArgumentException e ) {
}
assertFalse( pipe.isColored() );
assertTrue( pipe.isColoredAt( new Point( 0, 3 ) ) );
assertFalse( pipe.isColoredAt( new Point( 0, 4 ) ) );
pipe.setColored( new Point( 0, 1 ), false );
assertFalse( pipe.isColoredAt( new Point( 0, 1 ) ) );
assertTrue( pipe.isColoredAt( new Point( 0, 2 ) ) );
pipe.reset();
assertFalse( pipe.isColoredAt( new Point( 0, 2 ) ) );
for (int i = 1; i < 10; i++) {
pipe.setColored( new Point( 0, i ), true );
}
assertTrue( pipe.isColored() );
pipe.reset();
assertFalse( pipe.isColored() );
for (int i = 1; i < 4; i++) {
pipe.setColored( new Point( 0, i ), true );
}
for (int i = 9; i > 4; i--) {
pipe.setColored( new Point( 0, i ), true );
}
assertFalse( pipe.isColored() );
pipe.setColored( new Point( 0, 4 ), true );
assertTrue( pipe.isColored() );
}