-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: tests on environnement and hide print console
- Loading branch information
1 parent
7f5238c
commit 36bd30a
Showing
10 changed files
with
137 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
projet/funprog-al/src/test/scala/progFun/CSVExporterSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import org.scalatest.funsuite.AnyFunSuite | ||
import fr.esgi.al.funprog._ | ||
|
||
class CSVExporterSpec extends AnyFunSuite { | ||
|
||
test("Should export csv of mower") { | ||
val mower = SpecHelper.getTestMower(0, 1) | ||
|
||
assert(CSVExporter.export(mower) == "1,0,1,N,0,1,N,AADGA") | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
projet/funprog-al/src/test/scala/progFun/EnvironnementSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import org.scalatest.funsuite.AnyFunSuite | ||
import fr.esgi.al.funprog._ | ||
|
||
class EnvironnementSpec extends AnyFunSuite { | ||
|
||
test("Should get env filled with mowers") { | ||
val env = SpecHelper.getTestEnv() | ||
|
||
assert(env.mowers.length == 2) | ||
assert(env.limit_x == 5) | ||
assert(env.limit_y == 5) | ||
} | ||
|
||
test("Env should be executed and run all the mower actions turns") { | ||
val env = SpecHelper.getTestEnv() | ||
|
||
val executed = Environnement.execute(env) | ||
|
||
// assert 1nd mower position | ||
assert(executed.mowers(0).point.equals(new Point(1, 3))) | ||
assert(executed.mowers(0).direction.equals(North())) | ||
|
||
// assert 2nd mower position | ||
assert(executed.mowers(1).point.equals(new Point(5, 1))) | ||
assert(executed.mowers(1).direction.equals(East())) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package fr.esgi.al.funprog | ||
|
||
import fr.esgi.al.funprog._ | ||
|
||
class SpecHelper {} | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.DefaultArguments")) | ||
object SpecHelper { | ||
|
||
def getTestMower( | ||
x: Int = 0, | ||
y: Int = 0, | ||
directionStr: String = "N", | ||
actionsStr: String = "AADGA" | ||
): Mower = { | ||
val id = 1 | ||
val point = new Point(x, y) | ||
val direction = Direction(directionStr) | ||
val actions: List[Action] = | ||
actionsStr.split("").toList.map(s => Action(s)) | ||
|
||
new Mower( | ||
id, | ||
point, | ||
direction, | ||
point, | ||
direction, | ||
actions, | ||
actions | ||
) | ||
} | ||
|
||
def getTestEnv(): Environnement = { | ||
val mowers = List( | ||
getTestMower(1, 2, "N", "GAGAGAGAA"), | ||
getTestMower(3, 3, "E", "AADAADADDA") | ||
) | ||
|
||
val limit = new Point(5, 5) | ||
|
||
new Environnement( | ||
limit.x, | ||
limit.y, | ||
mowers, | ||
false, | ||
0 | ||
) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
5 5 | ||
#1 2 N | ||
#GAGAGAGAA | ||
1 2 N | ||
GAGAGAGAA | ||
3 3 E | ||
AADAADADDA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
numéro,début_x,début_y,début_direction,fin_x,fin_y,fin_direction,instructions | ||
1,3,3,E,5,1,E,AADAADADDA | ||
1,1,2,N,1,3,N,GAGAGAGAA | ||
2,3,3,E,5,1,E,AADAADADDA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters