github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/cmd/stringer/testdata/day.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 // Simple test: enumeration of type int starting at 0. 6 7 package main 8 9 import "fmt" 10 11 type Day int 12 13 const ( 14 Monday Day = iota 15 Tuesday 16 Wednesday 17 Thursday 18 Friday 19 Saturday 20 Sunday 21 ) 22 23 func main() { 24 ck(Monday, "Monday") 25 ck(Tuesday, "Tuesday") 26 ck(Wednesday, "Wednesday") 27 ck(Thursday, "Thursday") 28 ck(Friday, "Friday") 29 ck(Saturday, "Saturday") 30 ck(Sunday, "Sunday") 31 ck(-127, "Day(-127)") 32 ck(127, "Day(127)") 33 } 34 35 func ck(day Day, str string) { 36 if fmt.Sprint(day) != str { 37 panic("day.go: " + str) 38 } 39 }