I2P string format

This commit is contained in:
Hayden Parker
2016-02-04 00:54:51 -08:00
parent 7e32bd2458
commit e6cc4425c6
11 changed files with 76 additions and 17 deletions

31
lib/common/string_test.go Normal file
View File

@ -0,0 +1,31 @@
package common
import "testing"
func TestReadStringReadsLength(t *testing.T) {
bytes := []byte{0x01, 0x04, 0x06}
str, remainder, err := ReadString(bytes)
if err != nil {
t.Fatal("ReadString() returner error,", err)
}
if len(str) != 1 {
t.Fatal("ReadString() did not return correct string length:", len(str))
}
if str[0] != 0x04 {
t.Fatal("ReadString() did not return correct string")
}
if len(remainder) != 1 {
t.Fatal("ReadString() did not return correct remainder length")
}
if remainder[0] != 0x06 {
t.Fatal("ReadString() did not return correct remainder")
}
}
func TestReadStringErrWhenEmptySlice(t *testing.T) {
}
func TestReadStringErrWhenStringTooLong(t *testing.T) {
}