~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/fmt/fmt_test.go

  • Committer: Package Import Robot
  • Author(s): Ondřej Surý
  • Date: 2011-11-28 08:46:18 UTC
  • mfrom: (14.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20111128084618-pjgrpnkufjzxxjue
Tags: 1:60.3-1
Imported Upstream version 60.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
func (i I) String() string { return Sprintf("<%d>", int(i)) }
62
62
 
63
63
type B struct {
64
 
        i I
 
64
        I I
65
65
        j int
66
66
}
67
67
 
83
83
}
84
84
 
85
85
type S struct {
86
 
        f F // a struct field that Formats
87
 
        g G // a struct field that GoStrings
 
86
        F F // a struct field that Formats
 
87
        G G // a struct field that GoStrings
88
88
}
89
89
 
90
90
// A type with a String method with pointer receiver for testing %p
332
332
        {"%+v", A{1, 2, "a", []int{1, 2}}, `{i:1 j:2 s:a x:[1 2]}`},
333
333
 
334
334
        // +v on structs with Stringable items
335
 
        {"%+v", B{1, 2}, `{i:<1> j:2}`},
336
 
        {"%+v", C{1, B{2, 3}}, `{i:1 B:{i:<2> j:3}}`},
 
335
        {"%+v", B{1, 2}, `{I:<1> j:2}`},
 
336
        {"%+v", C{1, B{2, 3}}, `{i:1 B:{I:<2> j:3}}`},
337
337
 
338
338
        // q on Stringable items
339
339
        {"%s", I(23), `<23>`},
349
349
        {"%#v", uint64(1<<64 - 1), "0xffffffffffffffff"},
350
350
        {"%#v", 1000000000, "1000000000"},
351
351
        {"%#v", map[string]int{"a": 1, "b": 2}, `map[string] int{"a":1, "b":2}`},
352
 
        {"%#v", map[string]B{"a": {1, 2}, "b": {3, 4}}, `map[string] fmt_test.B{"a":fmt_test.B{i:1, j:2}, "b":fmt_test.B{i:3, j:4}}`},
 
352
        {"%#v", map[string]B{"a": {1, 2}, "b": {3, 4}}, `map[string] fmt_test.B{"a":fmt_test.B{I:1, j:2}, "b":fmt_test.B{I:3, j:4}}`},
353
353
        {"%#v", []string{"a", "b"}, `[]string{"a", "b"}`},
354
354
 
355
355
        // slices with other formats
384
384
        // Formatter
385
385
        {"%x", F(1), "<x=F(1)>"},
386
386
        {"%x", G(2), "2"},
387
 
        {"%+v", S{F(4), G(5)}, "{f:<v=F(4)> g:5}"},
 
387
        {"%+v", S{F(4), G(5)}, "{F:<v=F(4)> G:5}"},
388
388
 
389
389
        // GoStringer
390
390
        {"%#v", G(6), "GoString(6)"},
391
 
        {"%#v", S{F(7), G(8)}, "fmt_test.S{f:<v=F(7)>, g:GoString(8)}"},
 
391
        {"%#v", S{F(7), G(8)}, "fmt_test.S{F:<v=F(7)>, G:GoString(8)}"},
392
392
 
393
393
        // %T
394
394
        {"%T", (4 - 3i), "complex128"},