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 - check maximum size |
6 | |
7 | package main |
8 | |
9 | import "fmt" |
10 | |
11 | type Unum2 uint8 |
12 | |
13 | const ( |
14 | Zero Unum2 = iota |
15 | One |
16 | Two |
17 | ) |
18 | |
19 | func main() { |
20 | ck(Zero, "Zero") |
21 | ck(One, "One") |
22 | ck(Two, "Two") |
23 | ck(3, "Unum2(3)") |
24 | ck(255, "Unum2(255)") |
25 | } |
26 | |
27 | func ck(unum Unum2, str string) { |
28 | if fmt.Sprint(unum) != str { |
29 | panic("unum.go: " + str) |
30 | } |
31 | } |
32 |