github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/cmd/stringer/testdata/num.go (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Signed integers spanning zero. 6 7 package main 8 9 import "fmt" 10 11 type Num int 12 13 const ( 14 m_2 Num = -2 + iota 15 m_1 16 m0 17 m1 18 m2 19 ) 20 21 func main() { 22 ck(-3, "Num(-3)") 23 ck(m_2, "m_2") 24 ck(m_1, "m_1") 25 ck(m0, "m0") 26 ck(m1, "m1") 27 ck(m2, "m2") 28 ck(3, "Num(3)") 29 } 30 31 func ck(num Num, str string) { 32 if fmt.Sprint(num) != str { 33 panic("num.go: " + str) 34 } 35 }