-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.fs
71 lines (53 loc) · 2.44 KB
/
Tests.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module Tests
open Expecto
open StringCalc
[<Tests>]
let tests =
testList "Test Cases" [
testCase "Invalid expression1" <| fun _ ->
let subject = false
let actual = StringCalc("invalid")
Expect.equal actual -1001 "Invalid expression test fail"
testCase "Invalid expression2" <| fun _ ->
let subject = false
let actual = StringCalc("a,7")
Expect.equal actual -1001 "Invalid expression test fail"
testCase "Empty string" <| fun _ ->
let subject = false
let actual = StringCalc("")
Expect.equal actual 0 "Empty string test fail"
testCase "One number string" <| fun _ ->
let subject = false
let actual = StringCalc("1")
Expect.equal actual 1 "One number string test fail"
testCase "Add two numbers" <| fun _ ->
let actual = StringCalc("1,2")
Expect.equal actual 3 "Add two Numbers test fail"
testCase "Unkown numbers test" <| fun _ ->
let actual = StringCalc("1,2,5,50")
Expect.equal actual 58 "Unkown numbers test test fail"
testCase "Add multi numbers with new line delimiter" <| fun _ ->
let actual = StringCalc("1\n2,5,7")
Expect.equal actual 15 "add multi numbers with new line delimiter test fail"
testCase "Add multi numbers with custom delimiters" <| fun _ ->
let actual = StringCalc("//;\n1;2;7")
Expect.equal actual 10 "Add Multi numbers With new line delimiter test fail"
testCase "Negative numbers with custom delimiters" <| fun _ ->
let actual = StringCalc("//;\n1;-2")
Expect.equal actual -1002 "Negative numbers with custom delimiters Test Fail"
testCase "Negative numbers" <| fun _ ->
let actual = StringCalc("-1,2\n3")
Expect.equal actual -1002 "Negative numbers test fail"
testCase "Numbers bigger than 1000" <| fun _ ->
let actual = StringCalc("1001, 2")
Expect.equal actual 2 "Numbers bigger than 1000 test fail"
testCase "Multi char delimiters" <| fun _ ->
let actual = StringCalc("//[***]\n1***2***3")
Expect.equal actual 6 "Multi char delimiters test fail"
testCase "Multi delimiters" <| fun _ ->
let actual = StringCalc("//[*][%]\n1*2%3")
Expect.equal actual 6 "Multi delimiters test fail"
testCase "Multi char delimiters with multi delimiters" <| fun _ ->
let actual = StringCalc("//[***][%%%]\n1***2%%%3")
Expect.equal actual 6 "Multi char delimiters with multi delimiters test fail"
]