Skip to content

Commit 1e8ba9f

Browse files
authored
Implemented test unit for ps (#2)
Add more test unit
2 parents 50dd344 + b013fe9 commit 1e8ba9f

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

Diff for: purescript/test/tests/DividedBy.purs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module DividedBy where
2+
3+
import Prelude
4+
5+
import CodeWars.EightKyu.DividedBy (dividedBy, dividedByLogic, dividedByLogic2, dividedByWithoutAbs)
6+
import Test.Spec (Spec, describe, it)
7+
import Test.Spec.Assertions (shouldEqual, shouldNotEqual)
8+
9+
testDividedBy Spec Unit
10+
testDividedBy = do
11+
describe "dividedBy: a function to check if an integer `number` is divisible by both integers `a` and `b`." do
12+
13+
it "one of it is negative numbers" do
14+
dividedBy (-12) 2 6 `shouldEqual` true
15+
dividedBy (-12) 2 5 `shouldEqual` false
16+
dividedByWithoutAbs (-12) 2 (-6) `shouldEqual` true
17+
dividedByWithoutAbs (-12) 2 (-5) `shouldEqual` false
18+
19+
it "both negative numbers" do
20+
dividedBy (-24) (-12) 48 `shouldEqual` true
21+
dividedBy (-24) (-12) 48 `shouldNotEqual` false
22+
dividedByLogic (-24) (-2) 12 false `shouldEqual` true
23+
dividedByLogic2 (-24) (-2) 12 false `shouldEqual` true
24+
25+
it "returns negative number" do
26+
dividedByWithoutAbs (-100) 5 (-20) `shouldEqual` true
27+
dividedByLogic (-100) 5 (-20) false `shouldEqual` true
28+
dividedByLogic2 (-100) 5 (-20) false `shouldEqual` true

Diff for: purescript/test/tests/EightKyu.purs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ module Test.EightKyu where
22

33
import Prelude
44

5+
import DividedBy (testDividedBy)
56
import Realfloor (testRealFloor)
67
import Test.Spec (Spec)
78

89
eightKyu :: Spec Unit
910
eightKyu = do
10-
testRealFloor
11+
testRealFloor
12+
testDividedBy

Diff for: purescript/test/tests/Realfloor.purs

+14-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ import Test.Spec.Assertions (shouldEqual)
88

99
testRealFloor Spec Unit
1010
testRealFloor = do
11-
describe "" do
12-
it "" do
13-
realFloor 0 `shouldEqual` 0
11+
describe "realFloor: a function that given a floor in the american system returns the floor in the european system" do
12+
it "on the zeroth floor" do
13+
realFloor 0 `shouldEqual` 0
14+
it "the floor is lower than 13" do
15+
realFloor 3 `shouldEqual` 2
16+
realFloor 2 `shouldEqual` 1
17+
realFloor 1 `shouldEqual` 0
18+
realFloor 12 `shouldEqual` 11
19+
it "the floor is higher than 13" do
20+
realFloor 14 `shouldEqual` 12
21+
realFloor 20 `shouldEqual` 18
22+
it "underground floor" do
23+
realFloor (-1) `shouldEqual` (-1)
24+
realFloor (-12) `shouldEqual` (-12)

0 commit comments

Comments
 (0)