diff --git a/pdu/submit_test.go b/pdu/submit_test.go index 1ae1cd6..48a2661 100644 --- a/pdu/submit_test.go +++ b/pdu/submit_test.go @@ -76,8 +76,26 @@ func TestCalculateSizeTypicalInstance(t *testing.T) { schedule_delivery_time: "", validity_period: "", short_message: "Hello, World!", + data_coding: 1, } - expectedSize := 16 + len(p.service_type) + 1 + 1 + len(p.source_addr) + 1 + 1 + len(p.destination_addr) + 1 + 1 + 1 + len(p.schedule_delivery_time) + len(p.validity_period) + 1 + 1 + 1 + 1 + 1 + len(p.short_message) + expectedSize := 68 + actualSize := p.Size() + if actualSize != expectedSize { + t.Errorf("Expected size %d, but got %d", expectedSize, actualSize) + } +} + +func TestCalculateSizeTypicalGSM7Instance(t *testing.T) { + p := &SUBMIT_SM{ + service_type: "test_service", + source_addr: "12345", + destination_addr: "67890", + schedule_delivery_time: "", + validity_period: "", + short_message: "Hello, World!", + data_coding: 0, + } + expectedSize := 67 actualSize := p.Size() if actualSize != expectedSize { t.Errorf("Expected size %d, but got %d", expectedSize, actualSize) @@ -93,8 +111,9 @@ func TestCalculateSizeMaxLengths(t *testing.T) { schedule_delivery_time: string(make([]byte, maxLen)), validity_period: string(make([]byte, maxLen)), short_message: string(make([]byte, maxLen)), + data_coding: 1, } - expectedSize := 16 + maxLen + 1 + 1 + maxLen + 1 + 1 + maxLen + 1 + 1 + 1 + maxLen + maxLen + 1 + 1 + 1 + 1 + 1 + maxLen + expectedSize := 1563 actualSize := p.Size() if actualSize != expectedSize { t.Errorf("Expected size %d, but got %d", expectedSize, actualSize) @@ -110,7 +129,7 @@ func TestHandlesEmptyStringsForAllStringFields(t *testing.T) { validity_period: "", short_message: "", } - expectedSize := 16 + len(p.service_type) + 1 + 1 + len(p.source_addr) + 1 + 1 + len(p.destination_addr) + 1 + 1 + 1 + len(p.schedule_delivery_time) + len(p.validity_period) + 1 + 1 + 1 + 1 + 1 + len(p.short_message) + expectedSize := 33 actualSize := p.Size() if actualSize != expectedSize { t.Errorf("Expected size %d, but got %d", expectedSize, actualSize)