Skip to content
Snippets Groups Projects
Commit 359f2de1 authored by William Billingsley's avatar William Billingsley
Browse files

Switch to munit for Vec2D tests

parent 07fb8243
No related branches found
No related tags found
No related merge requests found
package cosc250.boids
import org.scalatest._
/**
*
*/
class Vec2Spec extends FlatSpec with Matchers {
"Vec2" should "be able to add vectors" in {
Vec2(1, 2) + Vec2(3, 4) should be (Vec2(4, 6))
}
it should "be able to subtract vectors" in {
Vec2(8, 9) - Vec2(3, 4) should be (Vec2(5, 5))
}
it should "be able to multiply a vector by a number" in {
Vec2(8, 9) * 4 should be (Vec2(32, 36))
}
it should "be able to divide a vector by a number" in {
Vec2(8, 6) / 2 should be (Vec2(4, 3))
}
it should "limit the size of a vector" in {
Vec2(10, 0).limit(5) should be (Vec2(5, 0))
}
it should "calculcate vectors from a direction and an angle in radians" in {
val Vec2(x, y) = Vec2.fromRTheta(4, Math.PI)
// There could be a rounding error -- these are doubles, so floor them as
// we know where Math.PI should go
Vec2(x.floor, y.floor) should be (Vec2(-4, 0))
}
}
package cosc250.boids
/**
*
*/
class Vec2Suite extends munit.FunSuite {
test("Vec2 should be able to add vectors") {
assertEquals(Vec2(1, 2) + Vec2(3, 4), Vec2(4, 6))
}
test("it should be able to subtract vectors") {
assertEquals(Vec2(8, 9) - Vec2(3, 4), Vec2(5, 5))
}
test("it should be able to multiply a vector by a number") {
assertEquals(Vec2(8, 9) * 4, Vec2(32, 36))
}
test("it should be able to divide a vector by a number") {
assertEquals(Vec2(8, 6) / 2, Vec2(4, 3))
}
test("it should limit the size of a vector") {
assertEquals(Vec2(10, 0).limit(5), Vec2(5, 0))
}
test("it should calculcate vectors from a direction and an angle in radians") {
val Vec2(x, y) = Vec2.fromRTheta(4, Math.PI)
// There could be a rounding error -- these are doubles, so floor them as
// we know where Math.PI should go
assertEquals(Vec2(x.floor, y.floor), Vec2(-4, 0))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment