Adding the challenge 0201

This commit is contained in:
2026-07-25 21:36:07 +02:00
parent 9c71ad1c8f
commit 19f6f8d323
8 changed files with 387 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package db0201
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/