Physics: Changed the way line segments are defined. They are now defined by the posit...
[kong.git] / test / net / habraun / kong / physics / LineSegmentTest.scala
blob5a959b32109c6ac32ad45946681e75fd16d60773
1 /*
2 Copyright (c) 2009 Hanno Braun <hanno@habraun.net>
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
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.
19 package net.habraun.kong.physics
23 import org.junit._
24 import org.junit.Assert._
28 class LineSegmentTest {
30 @Test
31 def verifyIsShape {
32 val segment = LineSegment(Vec2D(0, 0), Vec2D(10, 10))
33 assertTrue(segment.isInstanceOf[Shape])
38 @Test
39 def verifyHasAttributes {
40 val p = Vec2D(5, 5)
41 val d = Vec2D(2, 1)
42 val segment = LineSegment(p, d)
44 assertEquals(p, segment.p)
45 assertEquals(d, segment.d)
50 @Test { val expected = classOf[IllegalArgumentException] }
51 def createWithZeroDirectionVectorExpectException {
52 LineSegment(Vec2D(2, 2), Vec2D(0, 0))
57 @Test { val expected = classOf[NullPointerException] }
58 def createWithPositionVectorNullExpectException {
59 LineSegment(null, Vec2D(1, 1))
64 @Test { val expected = classOf[NullPointerException] }
65 def createWithDirectionVectorNullExpectException {
66 LineSegment(Vec2D(0, 0), null)