-
Notifications
You must be signed in to change notification settings - Fork 113
/
negative_tests.go
81 lines (65 loc) · 1.22 KB
/
negative_tests.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package checker_test
import (
"io/fs"
"io/ioutil"
"log"
"math"
"os"
)
func calculateInt(x int) int {
return x
}
func calculateHex(x int) int {
return x
}
func calculateFloat(x float64) float64 {
return x
}
func calculateString(x string) string {
return x
}
func NoWarningsCalc() {
_ = calculateInt(0)
_ = calculateInt(1)
_ = calculateInt(+1)
_ = calculateInt(-1)
_ = calculateInt(12)
_ = calculateInt(1 + 2)
var x = 0x3
_ = calculateInt(x)
_ = calculateHex(0x0)
_ = calculateHex(0X42)
_ = calculateHex(0xAA1)
_ = calculateHex(-0xaa1)
_ = calculateFloat(0.2)
_ = calculateFloat(+0.2)
_ = calculateFloat(-0.2)
_ = calculateString("1")
_ = calculateString("01")
_ = calculateString("0.1")
_, _ = calculateIntPair(1, 2)
_, _ = calculateIntPair(-1, 2)
_, _ = calculateIntPair(0, 2)
_ = 0b00
_ = 0b1
_ = 0b_0000_0101
_ = math.Exp(12)
_ = math.Exp(0x12)
_ = math.Max(12, 0xd)
_ = math.Min(0, 1)
}
func NoWarningsFs() {
_ = fs.FileMode(0o555)
}
func NoWarningsOs() {
f, err := os.OpenFile("notes.txt", os.O_RDWR|os.O_CREATE, 0o755)
if err != nil {
log.Fatal(err)
}
if err := f.Close(); err != nil {
log.Fatal(err)
}
}
func NoWarningsIoutil() {
_ = ioutil.WriteFile("notes.txt", nil, 0o666)
}