2015-12-29 16:14:54 +03:00
|
|
|
// Copyright 2014 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Unsigned integers - check maximum size
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
type Unum2 uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
Zero Unum2 = iota
|
|
|
|
One
|
|
|
|
Two
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
ck(Zero, "Zero")
|
|
|
|
ck(One, "One")
|
|
|
|
ck(Two, "Two")
|
2023-04-10 22:37:44 +03:00
|
|
|
ck(3, "")
|
|
|
|
ck(255, "")
|
2015-12-29 16:14:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func ck(unum Unum2, str string) {
|
|
|
|
if fmt.Sprint(unum) != str {
|
|
|
|
panic("unum.go: " + str)
|
|
|
|
}
|
|
|
|
}
|