Skip to content

Commit

Permalink
chore: fix test and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
manuandru committed Sep 8, 2023
1 parent 6f06efa commit 2bcc584
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package scatan.model.map
package scatan.model

import scatan.utils.UnorderedTriple
import scatan.utils.UnorderedTriple.given
import scatan.utils.UnorderedPair
import scatan.model.map.HexTiledMap.*
import scatan.model.map.{Hexagon, HexTiledMap, UndirectedGraph}

/** A Spot is unique identified by three hexagons in the map.
*
Expand Down
3 changes: 2 additions & 1 deletion src/test/scala/scatan/model/map/GameMapTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import scatan.BaseTest
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
import scatan.utils.UnorderedPair
import scatan.utils.UnorderedTriple
import scatan.model.{Spot, GameMap}

class GameMapTest extends BaseTest with ScalaCheckPropertyChecks:

val rangeToTest: Range = 0 to 5
val rangeToTest: Range = 0 to 4

"Hexagonal tiles in GameMap" should "obey to cubic coordinates rules" in {
rangeToTest foreach { (layer: Int) =>
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/scatan/utils/UnorderedTupleTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UnorderedPairTest extends BaseTest with ScalaCheckPropertyChecks:
it should "be not equals if, at least, one element is different" in {
val itemsInPair = 2
forAll { (a1: Int, b1: Int, a2: Int, b2: Int) =>
whenever(Set(a1, b1).intersect(Set(a2, b2)).sizeIs < itemsInPair) {
whenever((Set(a1, b1) | Set(a2, b2)).sizeIs > itemsInPair) {
val pair1 = UnorderedPair(a1, b1)
val pair2 = UnorderedPair(a2, b2)
pair1 should not be pair2
Expand Down Expand Up @@ -70,7 +70,7 @@ class UnorderedTripleTest extends BaseTest with ScalaCheckPropertyChecks:
it should "be not equals if, at least, one element is different" in {
val itemsInTriple = 3
forAll { (a1: Int, b1: Int, c1: Int, a2: Int, b2: Int, c2: Int) =>
whenever(Set(a1, b1, c1).intersect(Set(a2, b2, c2)).sizeIs < itemsInTriple) {
whenever((Set(a1, b1, c1) | Set(a2, b2, c2)).sizeIs > itemsInTriple) {
val triple1 = UnorderedTriple(a1, b1, c1)
val triple2 = UnorderedTriple(a2, b2, c2)
triple1 should not be triple2
Expand Down

0 comments on commit 2bcc584

Please sign in to comment.