-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunc_floor_test.go
53 lines (46 loc) · 1.07 KB
/
func_floor_test.go
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
package testing
import "testing"
func Test_Func_Floor_Ints(t *testing.T) {
rsl := `
print(floor(1))
`
setupAndRunCode(t, rsl, "--color=never")
assertOnlyOutput(t, stdOutBuffer, "1\n")
assertNoErrors(t)
}
func Test_Func_Floor_Negative_Ints(t *testing.T) {
rsl := `
print(floor(-2))
`
setupAndRunCode(t, rsl, "--color=never")
assertOnlyOutput(t, stdOutBuffer, "-2\n")
assertNoErrors(t)
}
func Test_Func_Floor_Floats(t *testing.T) {
rsl := `
print(floor(2.234))
`
setupAndRunCode(t, rsl, "--color=never")
assertOnlyOutput(t, stdOutBuffer, "2\n")
assertNoErrors(t)
}
func Test_Func_Floor_Negative_Floats(t *testing.T) {
rsl := `
print(floor(-2.234))
`
setupAndRunCode(t, rsl, "--color=never")
assertOnlyOutput(t, stdOutBuffer, "-3\n")
assertNoErrors(t)
}
func Test_Func_Floor_Errors_With_String(t *testing.T) {
rsl := `
print(floor("ab"))
`
setupAndRunCode(t, rsl, "--color=never")
expected := `Error at L2:13
print(floor("ab"))
^^^^
Got "string" as the 1st argument of floor(), but must be: float or int
`
assertError(t, 1, expected)
}