Export all fields in pdu

Oopsie!
This commit is contained in:
2024-07-31 15:10:46 +02:00
parent 4771ffa154
commit f1eb6b065d
8 changed files with 290 additions and 289 deletions

View File

@@ -9,28 +9,28 @@ import (
// See examples: https://www.openmarket.com/docs/Content/apis/v4smpp/mt-examples.htm
func TestEncodeFunctionCorrectlyEncodesAllFields(t *testing.T) {
p := &SUBMIT_SM{
header: &PDU_HEADER{
command_length: 0,
command_id: 4,
command_status: 0,
sequence_number: 378019,
Header: &PDU_HEADER{
Command_length: 0,
Command_id: 4,
Command_status: 0,
Sequence_number: 378019,
},
service_type: "OMV4",
source_addr_ton: 3,
source_addr_npi: 1,
source_addr: "80362",
dest_addr_ton: 1,
dest_addr_npi: 1,
destination_addr: "812345001000",
esm_class: 0,
protocol_id: 0,
priority_flag: 0,
schedule_delivery_time: "",
validity_period: "180105120000004+",
registered_delivery: 1,
data_coding: 1, // The example uses 0 and claims to use GSM but the message is encoded as ASCII...
sm_default_msg_id: 0,
short_message: "Reply Yes to opt in or No to opt out.",
Service_type: "OMV4",
Source_addr_ton: 3,
Source_addr_npi: 1,
Source_addr: "80362",
Dest_addr_ton: 1,
Dest_addr_npi: 1,
Destination_addr: "812345001000",
Esm_class: 0,
Protocol_id: 0,
Priority_flag: 0,
Schedule_delivery_time: "",
Validity_period: "180105120000004+",
Registered_delivery: 1,
Data_coding: 1, // The example uses 0 and claims to use GSM but the message is encoded as ASCII...
Sm_default_msg_id: 0,
Short_message: "Reply Yes to opt in or No to opt out.",
}
p.UpdateSize()
buf := ByteBufferPool.Get(p.Size())
@@ -47,28 +47,28 @@ func TestEncodeFunctionCorrectlyEncodesAllFields(t *testing.T) {
func TestEncodeFunctionCorrectlyEncodesAllFieldsGSM7Message(t *testing.T) {
p := &SUBMIT_SM{
header: &PDU_HEADER{
command_length: 0,
command_id: 4,
command_status: 0,
sequence_number: 378019,
Header: &PDU_HEADER{
Command_length: 0,
Command_id: 4,
Command_status: 0,
Sequence_number: 378019,
},
service_type: "OMV4",
source_addr_ton: 3,
source_addr_npi: 1,
source_addr: "80362",
dest_addr_ton: 1,
dest_addr_npi: 1,
destination_addr: "812345001000",
esm_class: 0,
protocol_id: 0,
priority_flag: 0,
schedule_delivery_time: "",
validity_period: "180105120000004+",
registered_delivery: 1,
data_coding: 0, // The example uses 0 and claims to use GSM but the message is encoded as ASCII...
sm_default_msg_id: 0,
short_message: "Reply Yes to opt in or No to opt out.",
Service_type: "OMV4",
Source_addr_ton: 3,
Source_addr_npi: 1,
Source_addr: "80362",
Dest_addr_ton: 1,
Dest_addr_npi: 1,
Destination_addr: "812345001000",
Esm_class: 0,
Protocol_id: 0,
Priority_flag: 0,
Schedule_delivery_time: "",
Validity_period: "180105120000004+",
Registered_delivery: 1,
Data_coding: 0, // The example uses 0 and claims to use GSM but the message is encoded as ASCII...
Sm_default_msg_id: 0,
Short_message: "Reply Yes to opt in or No to opt out.",
}
p.UpdateSize()
buf := ByteBufferPool.Get(p.Size())
@@ -88,13 +88,13 @@ func TestEncodeFunctionCorrectlyEncodesAllFieldsGSM7Message(t *testing.T) {
// region size
func TestCalculateSizeTypicalInstance(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: 1,
Service_type: "test_service",
Source_addr: "12345",
Destination_addr: "67890",
Schedule_delivery_time: "",
Validity_period: "",
Short_message: "Hello, World!",
Data_coding: 1,
}
expectedSize := 68
actualSize := p.Size()
@@ -105,13 +105,13 @@ func TestCalculateSizeTypicalInstance(t *testing.T) {
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,
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()
@@ -123,13 +123,13 @@ func TestCalculateSizeTypicalGSM7Instance(t *testing.T) {
func TestCalculateSizeMaxLengths(t *testing.T) {
maxLen := 255
p := &SUBMIT_SM{
service_type: string(make([]byte, maxLen)),
source_addr: string(make([]byte, maxLen)),
destination_addr: string(make([]byte, maxLen)),
schedule_delivery_time: string(make([]byte, maxLen)),
validity_period: string(make([]byte, maxLen)),
short_message: string(make([]byte, maxLen)),
data_coding: 1,
Service_type: string(make([]byte, maxLen)),
Source_addr: string(make([]byte, maxLen)),
Destination_addr: string(make([]byte, maxLen)),
Schedule_delivery_time: string(make([]byte, maxLen)),
Validity_period: string(make([]byte, maxLen)),
Short_message: string(make([]byte, maxLen)),
Data_coding: 1,
}
expectedSize := 1563
actualSize := p.Size()
@@ -140,12 +140,12 @@ func TestCalculateSizeMaxLengths(t *testing.T) {
func TestHandlesEmptyStringsForAllStringFields(t *testing.T) {
p := &SUBMIT_SM{
service_type: "",
source_addr: "",
destination_addr: "",
schedule_delivery_time: "",
validity_period: "",
short_message: "",
Service_type: "",
Source_addr: "",
Destination_addr: "",
Schedule_delivery_time: "",
Validity_period: "",
Short_message: "",
}
expectedSize := 33
actualSize := p.Size()