Physics: Changed Collision. It now consists of a time of impact and a contact point.
[kong.git] / test / net / habraun / kong / physics / CollisionTest.scala
blobb106021fbdf2d9c8bbff28238bf2aacb06105879
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 CollisionTest {
30 @Test
31 def verifyHasAttributes {
32 val t = 0.5
33 val contact = Contact(new Body, new Body, Vec2D(1, 0), Vec2D(-1, 0), Vec2D(5, 5))
34 val collision = Collision(t, contact)
35 assertEquals(t, collision.t, 0.0)
36 assertEquals(contact, collision.contact)
41 @Test { val expected = classOf[IllegalArgumentException] }
42 def createCollisionWithInvalidTime {
43 Collision(1.1, Contact(new Body, new Body, Vec2D(1, 0), Vec2D(-1, 0), Vec2D(5, 5)))
48 @Test { val expected = classOf[IllegalArgumentException] }
49 def createCollisionWithInvalidTime2 {
50 Collision(-1.0, Contact(new Body, new Body, Vec2D(1, 0), Vec2D(-1, 0), Vec2D(5, 5)))
55 @Test { val expected = classOf[NullPointerException] }
56 def createCollisionWithNullContact {
57 Collision(0.5, null)