Add coder/decoder size to coder
This commit is contained in:
@@ -70,7 +70,7 @@ func TestGSM7EncodeComplex8nASCIIString(t *testing.T) {
|
||||
func TestGSM7EncodeDoesNotAllocateMoreThanNecessary(t *testing.T) {
|
||||
coder := &GSM7Coder{}
|
||||
input := "Ducks are fucking great, they quacks, O quackers, what the fuck."
|
||||
buf := bytes.NewBuffer(make([]byte, GSM7EncodesInto(&input)))
|
||||
buf := bytes.NewBuffer(make([]byte, coder.EncodesInto(&input)))
|
||||
buf.Reset()
|
||||
|
||||
expected := buf.Cap()
|
||||
@@ -271,7 +271,7 @@ func TestDeletesLastValue(t *testing.T) {
|
||||
func TestGSM7EncodesIntoSmallString(t *testing.T) {
|
||||
input := short8nString
|
||||
expected := 7
|
||||
actual := GSM7EncodesInto(&input)
|
||||
actual := GSM7Coder{}.EncodesInto(&input)
|
||||
if actual != expected {
|
||||
t.Errorf("Expected %d, but got %d", expected, actual)
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func TestGSM7EncodesIntoSmallString(t *testing.T) {
|
||||
func TestGSM7EncodesIntoLargerNot8nString(t *testing.T) {
|
||||
input := longNot8nString
|
||||
expected := 33
|
||||
actual := GSM7EncodesInto(&input)
|
||||
actual := GSM7Coder{}.EncodesInto(&input)
|
||||
if actual != expected {
|
||||
t.Errorf("Expected %d, but got %d", expected, actual)
|
||||
}
|
||||
@@ -289,7 +289,7 @@ func TestGSM7EncodesIntoLargerNot8nString(t *testing.T) {
|
||||
func TestGSM7EncodesIntoLarger8nString(t *testing.T) {
|
||||
input := long8nString
|
||||
expected := 56
|
||||
actual := GSM7EncodesInto(&input)
|
||||
actual := GSM7Coder{}.EncodesInto(&input)
|
||||
if actual != expected {
|
||||
t.Errorf("Expected %d, but got %d", expected, actual)
|
||||
}
|
||||
@@ -298,7 +298,7 @@ func TestGSM7EncodesIntoLarger8nString(t *testing.T) {
|
||||
func TestGSM7DecodesIntoSmallString(t *testing.T) {
|
||||
input := short8nStringEncodedBytes
|
||||
expected := 8
|
||||
actual := GSM7DecodesInto(bytes.NewBuffer(input))
|
||||
actual := GSM7Coder{}.DecodesInto(bytes.NewBuffer(input))
|
||||
if actual != expected {
|
||||
t.Errorf("Expected %d, but got %d", expected, actual)
|
||||
}
|
||||
@@ -307,7 +307,7 @@ func TestGSM7DecodesIntoSmallString(t *testing.T) {
|
||||
func TestGSM7DecodesIntoLargerNot8nString(t *testing.T) {
|
||||
input := longNot8nStringEncodedBytes
|
||||
expected := 37
|
||||
actual := GSM7DecodesInto(bytes.NewBuffer(input))
|
||||
actual := GSM7Coder{}.DecodesInto(bytes.NewBuffer(input))
|
||||
if actual != expected {
|
||||
t.Errorf("Expected %d, but got %d", expected, actual)
|
||||
}
|
||||
@@ -316,7 +316,7 @@ func TestGSM7DecodesIntoLargerNot8nString(t *testing.T) {
|
||||
func TestGSM7DecodesIntoLarger8nString(t *testing.T) {
|
||||
input := long8nStringEncodedBytes
|
||||
expected := 64
|
||||
actual := GSM7DecodesInto(bytes.NewBuffer(input))
|
||||
actual := GSM7Coder{}.DecodesInto(bytes.NewBuffer(input))
|
||||
if actual != expected {
|
||||
t.Errorf("Expected %d, but got %d", expected, actual)
|
||||
}
|
||||
@@ -362,7 +362,7 @@ func BenchmarkGSM7EncodeComplex8nASCIIStringPrealloc(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf := bytes.NewBuffer(make([]byte, GSM7EncodesInto(&input)))
|
||||
buf := bytes.NewBuffer(make([]byte, coder.EncodesInto(&input)))
|
||||
buf.Reset()
|
||||
coder.Encode(&input, buf)
|
||||
}
|
||||
|
Reference in New Issue
Block a user