Rework every uint8 to byte and rework every []byte to bytes.Buffer
Some checks failed
Benchmark BufferPool / RunBenchmarks (push) Failing after 17s
Run Tests / Test (push) Failing after 15s

I just learnt that uint8 and byte are the fucking same
And that bytes.Buffer is the thing to use
Idiot idiot idiot...
Live and learn
This commit is contained in:
2024-07-24 18:43:18 +02:00
parent bed69fbfd3
commit f30680c26f
9 changed files with 461 additions and 418 deletions

View File

@@ -14,7 +14,7 @@ func TestCalculateSizeTypicalInstance(t *testing.T) {
validity_period: "",
short_message: "Hello, World!",
}
expectedSize := uint32(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 := 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)
actualSize := p.Size()
if actualSize != expectedSize {
t.Errorf("Expected size %d, but got %d", expectedSize, actualSize)
@@ -31,7 +31,7 @@ func TestCalculateSizeMaxLengths(t *testing.T) {
validity_period: string(make([]byte, maxLen)),
short_message: string(make([]byte, maxLen)),
}
expectedSize := uint32(16 + maxLen + 1 + 1 + maxLen + 1 + 1 + maxLen + 1 + 1 + 1 + maxLen + maxLen + 1 + 1 + 1 + 1 + 1 + maxLen)
expectedSize := 16 + maxLen + 1 + 1 + maxLen + 1 + 1 + maxLen + 1 + 1 + 1 + maxLen + maxLen + 1 + 1 + 1 + 1 + 1 + maxLen
actualSize := p.Size()
if actualSize != expectedSize {
t.Errorf("Expected size %d, but got %d", expectedSize, actualSize)
@@ -47,7 +47,7 @@ func TestHandlesEmptyStringsForAllStringFields(t *testing.T) {
validity_period: "",
short_message: "",
}
expectedSize := uint32(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 := 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)
actualSize := p.Size()
if actualSize != expectedSize {
t.Errorf("Expected size %d, but got %d", expectedSize, actualSize)