@@ -5,25 +5,23 @@ import (
55 "bytes"
66 "fmt"
77 "strings"
8- "testing"
8+
9+ . "launchpad.net/gocheck"
910)
1011
11- func TestRFC6587_GetSplitFuncSingleSplit (t * testing. T ) {
12+ func ( s * FormatSuite ) TestRFC6587_GetSplitFuncSingleSplit (c * C ) {
1213 f := RFC6587 {}
1314
14- find := "I am test."
15- buf := strings .NewReader ("10 " + find )
15+ buf := strings .NewReader ("10 I am test." )
1616 scanner := bufio .NewScanner (buf )
1717 scanner .Split (f .GetSplitFunc ())
18- if r := scanner .Scan (); ! r {
19- t .Error ("Expected Scan() to return true, but didn't" )
20- }
21- if found := scanner .Text (); found != find {
22- t .Errorf ("Expected the right ('%s') token, but got: '%s'\n " , find , found )
23- }
18+
19+ r := scanner .Scan ()
20+ c .Assert (r , NotNil )
21+ c .Assert (scanner .Text (), Equals , "I am test." )
2422}
2523
26- func TestRFC6587_GetSplitFuncMultiSplit (t * testing. T ) {
24+ func ( s * FormatSuite ) TestRFC6587_GetSplitFuncMultiSplit (c * C ) {
2725 f := RFC6587 {}
2826
2927 find := []string {
@@ -40,35 +38,28 @@ func TestRFC6587_GetSplitFuncMultiSplit(t *testing.T) {
4038
4139 i := 0
4240 for scanner .Scan () {
41+ c .Assert (scanner .Text (), Equals , find [i ])
4342 i ++
4443 }
4544
46- if i != len (find ) {
47- t .Errorf ("Expected to find %d items, but found: %d\n " , len (find ), i )
48- }
45+ c .Assert (i , Equals , len (find ))
4946}
5047
51- func TestRFC6587_GetSplitBadSplit (t * testing. T ) {
48+ func ( s * FormatSuite ) TestRFC6587_GetSplitBadSplit (c * C ) {
5249 f := RFC6587 {}
5350
5451 find := "I am test.2 ab"
5552 buf := strings .NewReader ("9 " + find )
5653 scanner := bufio .NewScanner (buf )
5754 scanner .Split (f .GetSplitFunc ())
5855
59- if r := scanner .Scan (); ! r {
60- t .Error ("Expected Scan() to return true, but didn't" )
61- }
62- if found := scanner .Text (); found != find [0 :9 ] {
63- t .Errorf ("Expected to find %s, but found %s." , find [0 :9 ], found )
64- }
65- if r := scanner .Scan (); r {
66- t .Error ("Expected Scan() to return false, but didn't" )
67- }
68- if err := scanner .Err (); err == nil {
69- t .Error ("Expected an error, but didn't get one" )
70- } else {
71- t .Log ("Error was: " , err )
72- }
56+ r := scanner .Scan ()
57+ c .Assert (r , NotNil )
58+ c .Assert (scanner .Text (), Equals , find [0 :9 ])
59+
60+ r = scanner .Scan ()
61+ c .Assert (r , NotNil )
7362
63+ err := scanner .Err ()
64+ c .Assert (err , ErrorMatches , "strconv.ParseInt: parsing \" .2\" : invalid syntax" )
7465}
0 commit comments