define redisError type
parent
2013eb44cd
commit
a1cdead607
@ -1,16 +1,32 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleString(t *testing.T) {
|
var valueTests = []struct {
|
||||||
s, err := readValue([]byte(`+hello`))
|
in string
|
||||||
if err != nil {
|
out value
|
||||||
t.Errorf("bad input: %v", err)
|
}{
|
||||||
}
|
{"+hello", simpleString("hello")},
|
||||||
if s != simpleString("hello") {
|
{"+one two", simpleString("one two")}, // intermediate space
|
||||||
t.Errorf("expected 'hello', got '%s'", s)
|
{"+one two ", simpleString("one two ")}, // trailing space
|
||||||
}
|
{"+ one two", simpleString(" one two")}, // leading space
|
||||||
|
|
||||||
|
{"-hello", redisError("hello")},
|
||||||
|
{"-one two", redisError("one two")}, // intermediate space
|
||||||
|
{"-one two ", redisError("one two ")}, // trailing space
|
||||||
|
{"- one two", redisError(" one two")}, // leading space
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValues(t *testing.T) {
|
||||||
|
for _, test := range valueTests {
|
||||||
|
v, err := readValue([]byte(test.in))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed value test: %v", err)
|
||||||
|
}
|
||||||
|
if v != test.out {
|
||||||
|
t.Errorf("expected %v, got %v", test.out, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue