yeah this test wasn't very good before.

master
Jordan Orelli 10 years ago
parent 738881cf97
commit 2834dec785

@ -48,7 +48,7 @@ func readValue(r io.Reader) (value, error) {
line, err := br.ReadBytes('\n') line, err := br.ReadBytes('\n')
switch err { switch err {
case io.EOF: case io.EOF:
if line != nil { if line != nil && len(line) > 0 {
break break
} }
return nil, err return nil, err
@ -109,7 +109,7 @@ func readInteger(b []byte) (value, error) {
return Integer(i), nil return Integer(i), nil
} }
// ----------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
type BulkString string type BulkString string

@ -130,15 +130,24 @@ func (s streamTest) run(t *testing.T) {
c, e := make(chan value), make(chan error) c, e := make(chan value), make(chan error)
r := strings.NewReader(s[0].(string)) r := strings.NewReader(s[0].(string))
go streamValues(r, c, e) go streamValues(r, c, e)
for i := 1; i < len(s); i++ { count := 1
for {
select { select {
case v := <-c: case v, ok := <-c:
if !eq(s[i], v) { if !ok {
t.Errorf("expected %v, got %v", s[i], v) return
}
if !eq(s[count], v) {
t.Errorf("expected %q, got %q", s[count], v)
}
case err, ok := <-e:
if !ok {
return
} }
case err := <-e:
t.Error(err) t.Error(err)
return
} }
count++
} }
} }

Loading…
Cancel
Save