Contact: Contacts are now represented by two different contact objects, each viewing...
[scd.git] / test / net / habraun / sd / CollisionTest.scala
blob65239e37fd9473203517eb5c03a2f0f350831d72
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.sd
23 import math._
25 import org.junit._
26 import org.junit.Assert._
30 class CollisionTest {
32 @Test
33 def verifyHasAttributes {
34 val t = 0.5
35 val contact1 = Contact(new Body, Vec2D(5, 5), Vec2D(1, 0), new Body)
36 val contact2 = Contact(new Body, Vec2D(6, 6), Vec2D(-1, 0), new Body)
37 val collision = Collision(t, contact1, contact2)
38 assertEquals(t, collision.t, 0.0)
39 assertEquals(contact1, collision.contact1)
40 assertEquals(contact2, collision.contact2)
45 @Test { val expected = classOf[IllegalArgumentException] }
46 def createCollisionWithInvalidTime {
47 val contact = Contact(new Body, Vec2D(5, 5), Vec2D(1, 0), new Body)
48 Collision(1.1, contact, contact)
53 @Test { val expected = classOf[IllegalArgumentException] }
54 def createCollisionWithInvalidTime2 {
55 val contact = Contact(new Body, Vec2D(5, 5), Vec2D(1, 0), new Body)
56 Collision(-1.0, contact, contact)
61 @Test { val expected = classOf[NullPointerException] }
62 def createCollisionWithNullContact1 {
63 Collision(0.5, null, Contact(new Body, Vec2D(5, 5), Vec2D(1, 0), new Body))
68 @Test { val expected = classOf[NullPointerException] }
69 def createCollisionWithNullContact2 {
70 Collision(0.5, Contact(new Body, Vec2D(5, 5), Vec2D(1, 0), new Body), null)