Adding the challenge 0301

This commit is contained in:
2026-07-29 22:54:42 +02:00
parent df8c61b7b9
commit 89975de979
15 changed files with 807 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package db0301
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTableCell(t *testing.T) {
cell := Cell{Type: TypeI64, I64: -2}
data := []byte{0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
assert.Equal(t, data, cell.Encode(nil))
decoded := Cell{Type: TypeI64}
rest, err := decoded.Decode(data)
assert.True(t, len(rest) == 0 && err == nil)
assert.Equal(t, cell, decoded)
cell = Cell{Type: TypeStr, Str: []byte("asdf")}
data = []byte{4, 0, 0, 0, 'a', 's', 'd', 'f'}
assert.Equal(t, data, cell.Encode(nil))
decoded = Cell{Type: TypeStr}
rest, err = decoded.Decode(data)
assert.True(t, len(rest) == 0 && err == nil)
assert.Equal(t, cell, decoded)
}
// QzBQWVJJOUhU https://trialofcode.org/