-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
43 lines (37 loc) · 1.04 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"testing"
)
func TestRespInteger5(t *testing.T) {
bytesInt := respInteger(666)
if string(bytesInt) != ":666\r\n" {
t.Error("respInteger not returning resp comply string")
}
}
func TestRespIntegerNeg(t *testing.T) {
bytesInt := respInteger(-1)
if string(bytesInt) != ":-1\r\n" {
t.Error("respInteger not returning resp comply string")
}
}
func TestRespError(t *testing.T) {
bytesError := respError("Unknown Command")
if string(bytesError) != "-ERR Unknown Command\r\n" {
t.Error("respError not returning resp comply string")
}
}
func TestRespBulkString(t *testing.T) {
bulkString := "SET mykey Hello"
bytesBulk := respBulkString([]byte(bulkString))
if string(bytesBulk) != fmt.Sprintf("$%d\r\n%s\r\n", len(bulkString), bulkString) {
t.Error("respError not returning resp comply string")
}
}
func TestRespSimpleString(t *testing.T) {
bulkString := "OK"
bytesBulk := respSimpleString("OK")
if string(bytesBulk) != fmt.Sprintf("+%s\r\n", bulkString) {
t.Error("respError not returning resp comply string")
}
}