Skip to content
Snippets Groups Projects
Commit ea07eefd authored by kiady.arintsoa's avatar kiady.arintsoa :man_with_turban_tone2:
Browse files

Merge branch 'edit-test1' into 'main'

Migrate from FunSuite to WordSpec for ex1

See merge request kiady.arintsoa/advprog-exercises!3
parents 51e2a88e 96976a71
Branches
No related tags found
No related merge requests found
package ex1
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
class Ex1Spec extends AnyWordSpec with Matchers {
"The first function" must {
"create a list of numbers which are consecutive multiples of 3" in {
One() should be(List(3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45,
48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81))
}
}
"The second function" must {
"generate a new list where each element is tripled" in {
Two(List(3, 5, 2, 3, 9, 4, 2)) should be(List(9, 15, 6, 9, 27, 12, 6))
}
}
"The third function" must {
"keep only elements with decimal part > 0.5" in {
Three(List(45.6, 23.1, 22.7, 32.2)) should be(List(45.6, 22.7))
}
}
"The fourth function" must {
"map to (capitalized, length) then filter start with 'L' and finally show biggest" in {
Four(List("jim", "lara", "linda", "john", "barry")) should be(5)
}
}
}
package ex1
import org.scalatest.funsuite.AnyFunSuite
class Ex1Suite extends AnyFunSuite {
test("1. Create a list of numbers which are consecutive multiples of 3") {
assert(
One() == List(3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45,
48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81)
)
}
test("2. Generate a new list where each element is tripled") {
assert(Two(List(3, 5, 2, 3, 9, 4, 2)) == List(9, 15, 6, 9, 27, 12, 6))
}
test("3. Keep only elements with decimal > 0.5") {
assert(Three(List(45.6, 23.1, 22.7, 32.2)) == List(45.6, 22.7))
}
test("4. To map (capitalized, length), filter start with L, show biggest") {
assert(Four(List("jim", "lara", "linda", "john", "barry")) == 5)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment