Files
db_in_45_steps_go/0202/cell_test.go
T
2026-07-26 21:48:08 +02:00

28 lines
726 B
Go

package db0202
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/