Source file
test/fixedbugs/issue24817.go
1
2
3
4
5
6
7
8
9 package main
10
11 import (
12 "fmt"
13 "os"
14 )
15
16 var (
17 s = "abc"
18 e = ""
19 failed bool
20 )
21
22 func main() {
23 want(true, "" < s, `"" < s`)
24 want(false, s < "", `s < ""`)
25 want(false, "" < e, `"" < e`)
26 want(false, e < "", `e < ""`)
27
28 want(true, "" <= s, `"" <= s`)
29 want(false, s <= "", `s <= ""`)
30 want(true, "" <= e, `"" <= e`)
31 want(true, e <= "", `e <= ""`)
32
33 want(false, "" > s, `"" > s`)
34 want(true, s > "", `s > ""`)
35 want(false, "" > e, `"" > e`)
36 want(false, e > "", `e > ""`)
37
38 want(false, "" >= s, `"" >= s`)
39 want(true, s >= "", `s >= ""`)
40 want(true, "" >= e, `"" >= e`)
41 want(true, e >= "", `e >= ""`)
42
43 want(false, "" == s, `"" == s`)
44 want(false, s == "", `s == ""`)
45 want(true, "" == e, `"" == e`)
46 want(true, e == "", `e == ""`)
47
48 want(true, "" != s, `"" != s`)
49 want(true, s != "", `s != ""`)
50 want(false, "" != e, `"" != e`)
51 want(false, e != "", `e != ""`)
52
53 if failed {
54 os.Exit(1)
55 }
56 }
57
58
59 func want(b bool, have bool, msg string) {
60 if b != have {
61 fmt.Println(msg)
62 failed = true
63 }
64 }
65
View as plain text