diff --git a/encoding/gsm7_test.go b/encoding/gsm7_test.go index 166fcfc..e1cda9e 100644 --- a/encoding/gsm7_test.go +++ b/encoding/gsm7_test.go @@ -22,6 +22,40 @@ func TestGSM7EncodeSimpleASCIIString(t *testing.T) { } } +func TestGSM7EncodeComplexASCIIString(t *testing.T) { + coder := &GSM7Coder{} + var buf bytes.Buffer + input := "Golden rays play, Chasing night away." + + expected := []byte{0b11000111, 0b00110111, 0b10011011, 0b01011100, 0b01110110, 0b10000011, 0b11100100, 0b11100001, 0b11111100, 0b00011100, 0b00000100, 0b01100111, 0b10000111, 0b11110011, 0b00101100, 0b11010000, 0b00010000, 0b00011101, 0b10011110, 0b10100111, 0b11011101, 0b01100111, 0b10010000, 0b00111011, 0b01111101, 0b01000110, 0b11010011, 0b01000001, 0b11100001, 0b01111011, 0b00111000, 0b11101111, 0b00000010} + err := coder.Encode(input, &buf) + + if err != nil { + t.Errorf("Expected no error, but got %v", err) + } + + if !bytes.Equal(buf.Bytes(), expected) { + t.Errorf("Expected %v, but got %v", expected, buf.Bytes()) + } +} + +func TestGSM7EncodeEmptyString(t *testing.T) { + coder := &GSM7Coder{} + var buf bytes.Buffer + input := "" + + expected := []byte{} + err := coder.Encode(input, &buf) + + if err != nil { + t.Errorf("Expected no error, but got %v", err) + } + + if !bytes.Equal(buf.Bytes(), expected) { + t.Errorf("Expected %v, but got %v", expected, buf.Bytes()) + } +} + func TestGSM7DecodeSimpleASCIIString(t *testing.T) { coder := &GSM7Coder{} var buf bytes.Buffer @@ -40,20 +74,21 @@ func TestGSM7DecodeSimpleASCIIString(t *testing.T) { } } -func TestGSM7EncodeEmptyString(t *testing.T) { +func TestGSM7DecodeComplexASCIIString(t *testing.T) { coder := &GSM7Coder{} var buf bytes.Buffer - input := "" + input := []byte{0b11010011, 0b10111010, 0b01111011, 0b10001110, 0b01001110, 0b10111011, 0b11001011} - expected := []byte{} - err := coder.Encode(input, &buf) + expected := "Golden rays play, Chasing night away." + buf.Write(input) + output, err := coder.Decode(&buf) if err != nil { t.Errorf("Expected no error, but got %v", err) } - if !bytes.Equal(buf.Bytes(), expected) { - t.Errorf("Expected %v, but got %v", expected, buf.Bytes()) + if output != expected { + t.Errorf("Expected %v, but got %v", expected, output) } }