OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [strconv/] [atob_test.go] - Blame information for rev 775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// 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.
4
 
5
package strconv_test
6
 
7
import (
8
        . "strconv"
9
        "testing"
10
)
11
 
12
type atobTest struct {
13
        in  string
14
        out bool
15
        err error
16
}
17
 
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},
33
}
34
 
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)
46
                                }
47
                        }
48
                } else {
49
                        if e != nil {
50
                                t.Errorf("%s: expected no error but got %s", test.in, e)
51
                        }
52
                        if b != test.out {
53
                                t.Errorf("%s: expected %t but got %t", test.in, test.out, b)
54
                        }
55
                }
56
        }
57
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.