* gcc.misc-tests/gcov-14.c: Skip on AIX.
[official-gcc.git] / libgo / go / strconv / atob_test.go
bloba7c1454eb1ef9390d63b7f5048181b1ebb05dcf9
1 // Copyright 2009 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.
5 package strconv_test
7 import (
8 . "strconv"
9 "testing"
12 type atobTest struct {
13 in string
14 out bool
15 err error
18 var atobtests = []atobTest{
19 {"", false, ErrSyntax},
20 {"asdf", false, ErrSyntax},
21 {"0", false, nil},
22 {"f", false, nil},
23 {"F", false, nil},
24 {"FALSE", false, nil},
25 {"false", false, nil},
26 {"False", false, nil},
27 {"1", true, nil},
28 {"t", true, nil},
29 {"T", true, nil},
30 {"TRUE", true, nil},
31 {"true", true, nil},
32 {"True", true, nil},
35 func TestParseBool(t *testing.T) {
36 for _, test := range atobtests {
37 b, e := ParseBool(test.in)
38 if test.err != nil {
39 // expect an error
40 if e == nil {
41 t.Errorf("%s: expected %s but got nil", test.in, test.err)
42 } else {
43 // NumError assertion must succeed; it's the only thing we return.
44 if test.err != e.(*NumError).Err {
45 t.Errorf("%s: expected %s but got %s", test.in, test.err, e)
48 } else {
49 if e != nil {
50 t.Errorf("%s: expected no error but got %s", test.in, e)
52 if b != test.out {
53 t.Errorf("%s: expected %t but got %t", test.in, test.out, b)