github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/cmd/stringer/testdata/unum.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  // Unsigned integers spanning zero.
     6  
     7  package main
     8  
     9  import "fmt"
    10  
    11  type Unum uint8
    12  
    13  const (
    14  	m_2 Unum = iota + 253
    15  	m_1
    16  )
    17  
    18  const (
    19  	m0 Unum = iota
    20  	m1
    21  	m2
    22  )
    23  
    24  func main() {
    25  	ck(^Unum(0)-3, "Unum(252)")
    26  	ck(m_2, "m_2")
    27  	ck(m_1, "m_1")
    28  	ck(m0, "m0")
    29  	ck(m1, "m1")
    30  	ck(m2, "m2")
    31  	ck(3, "Unum(3)")
    32  }
    33  
    34  func ck(unum Unum, str string) {
    35  	if fmt.Sprint(unum) != str {
    36  		panic("unum.go: " + str)
    37  	}
    38  }