Implement GSM7 packing
Some checks failed
Benchmark BufferPool / RunBenchmarks (push) Has been cancelled
Run Tests / Test (push) Has been cancelled

This commit is contained in:
2024-07-28 13:00:34 +02:00
parent 92c0e83e73
commit 7f9717266f
2 changed files with 64 additions and 13 deletions

View File

@@ -10,8 +10,12 @@ func TestGSM7EncodeSimpleASCIIString(t *testing.T) {
var buf bytes.Buffer
input := "Sunshine"
expected := []byte{0b11010011, 0b10111001, 0b10111011, 0b10001110, 0b01001110, 0b10111011, 0b11001011}
coder.Encode(input, &buf)
expected := []byte{0b11010011, 0b10111010, 0b01111011, 0b10001110, 0b01001110, 0b10111011, 0b11001011}
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())
@@ -21,11 +25,15 @@ func TestGSM7EncodeSimpleASCIIString(t *testing.T) {
func TestGSM7DecodeSimpleASCIIString(t *testing.T) {
coder := &GSM7Coder{}
var buf bytes.Buffer
input := []byte{0b11010011, 0b10111001, 0b10111011, 0b10001110, 0b01001110, 0b10111011, 0b11001011}
input := []byte{0b11010011, 0b10111010, 0b01111011, 0b10001110, 0b01001110, 0b10111011, 0b11001011}
expected := "Sunshine"
buf.Write(input)
output := coder.Decode(&buf)
output, err := coder.Decode(&buf)
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if output != expected {
t.Errorf("Expected %v, but got %v", expected, output)
@@ -38,7 +46,11 @@ func TestGSM7EncodeEmptyString(t *testing.T) {
input := ""
expected := []byte{}
coder.Encode(input, &buf)
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())
@@ -50,7 +62,11 @@ func TestGSM7DecodeEmptyString(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
expected := ""
output := coder.Decode(buf)
output, err := coder.Decode(buf)
if err != nil {
t.Errorf("Expected no error, but got %v", err)
}
if output != expected {
t.Errorf("Expected %v, but got %v", expected, output)