Debian Codegraph @

staticcheck/sa4003/testdata/go1.0/CheckExtremeComparison/CheckExtremeComparison.go

raw
1 package pkg
2
3 import "math"
4
5 func fn1() {
6 var (
7 u8 uint8
8 u16 uint16
9 u uint
10
11 i8 int8
12 i16 int16
13 i int
14 )
15
16 _ = u8 > math.MaxUint8 //@ diag(`no value of type uint8 is greater than math.MaxUint8`)
17 _ = u8 >= math.MaxUint8 //@ diag(`no value of type uint8 is greater than math.MaxUint8`)
18 _ = u8 >= 0 //@ diag(`every value of type uint8 is >= 0`)
19 _ = u8 <= math.MaxUint8 //@ diag(`every value of type uint8 is <= math.MaxUint8`)
20 _ = u8 > 0
21 _ = u8 >= 1
22 _ = u8 < math.MaxUint8
23 _ = u8 < 0 //@ diag(`no value of type uint8 is less than 0`)
24 _ = u8 <= 0
25 _ = 0 > u8 //@ diag(`no value of type uint8 is less than 0`)
26 _ = 0 >= u8
27
28 _ = u16 > math.MaxUint8
29 _ = u16 > math.MaxUint16 //@ diag(`no value of type uint16 is greater than math.MaxUint16`)
30 _ = u16 <= math.MaxUint8
31 _ = u16 <= math.MaxUint16 //@ diag(`every value of type uint16 is <= math.MaxUint16`)
32
33 _ = u > math.MaxUint32
34
35 _ = i8 > math.MaxInt8 //@ diag(`no value of type int8 is greater than math.MaxInt8`)
36 _ = i16 > math.MaxInt8
37 _ = i16 > math.MaxInt16 //@ diag(`no value of type int16 is greater than math.MaxInt16`)
38 _ = i > math.MaxInt32
39 _ = i8 < 0
40 _ = i8 <= math.MinInt8 //@ diag(`no value of type int8 is less than math.MinInt8`)
41 _ = i8 < math.MinInt8 //@ diag(`no value of type int8 is less than math.MinInt8`)
42 _ = i8 >= math.MinInt8 //@ diag(`every value of type int8 is >= math.MinInt8`)
43
44 _ = i8 > -128
45 _ = i8 >= -128 //@ diag(`every value of type int8 is >= math.MinInt8`)
46 _ = i8 < 127
47 _ = i8 <= 127 //@ diag(`every value of type int8 is <= math.MaxInt8`)
48 _ = i8 > 127 //@ diag(`no value of type int8 is greater than math.MaxInt8`)
49 _ = i8 >= 127 //@ diag(`no value of type int8 is greater than math.MaxInt8`)
50
51 _ = u8 < 255
52 _ = u8 <= 255 //@ diag(`every value of type uint8 is <= math.MaxUint8`)
53 _ = u8 > 255 //@ diag(`no value of type uint8 is greater than math.MaxUint8`)
54 _ = u8 >= 255 //@ diag(`no value of type uint8 is greater than math.MaxUint8`)
55
56 const k = 255
57 _ = u8 <= k
58 }