-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
factorial_demo_test.puml
32 lines (28 loc) · 1.03 KB
/
factorial_demo_test.puml
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
@startuml
!include factorial_demo.puml
!$test_data = {
"tests" : [
{"input": "0", "output": "1"},
{"input": "1", "output": "1"},
{"input": "2", "output": "2"},
{"input": "3", "output": "6"},
{"input": "4", "output": "24"},
{"input": "5", "output": "120"},
{"input": "6", "output": "720"},
{"input": "7", "output": "5040"},
{"input": "8", "output": "40320"},
{"input": "9", "output": "362880"},
{"input": "10", "output": "3628800"},
{"input": "11", "output": "39916800"},
{"input": "12", "output": "479001600"},
/' below input will raise an assert, but there's currently no way to
"expect" an assert, preprocessor is not a unit testing framework. ;-) '/
{"input": "-1", "output": "0"}
]
}
!foreach $item in $test_data.tests
!$expected = %intval($item.output)
!$actual = $factorial(%intval($item.input))
!assert $expected == $actual : "expected [" + $expected + "] actual [" + $actual + "]"
!endfor
@enduml