测试:完善和优化测试用例

- 优化 schema 测试用例,增加边界条件测试
- 完善 table、index、database 等模块的测试
- 改进测试数据清理和错误处理
- 更新示例程序以使用最新 API
- 增强测试覆盖率和可靠性
This commit is contained in:
2025-10-09 21:47:14 +08:00
parent 89af9e9259
commit 6d04487789
14 changed files with 812 additions and 132 deletions

View File

@@ -16,10 +16,13 @@ func TestSSTable(t *testing.T) {
defer os.Remove("test.sst")
// 创建 Schema
schema := NewSchema("test", []Field{
schema, err := NewSchema("test", []Field{
{Name: "name", Type: FieldTypeString},
{Name: "age", Type: FieldTypeInt64},
})
if err != nil {
t.Fatal(err)
}
// 2. 写入数据
writer := NewSSTableWriter(file, schema)
@@ -164,9 +167,12 @@ func TestSSTableHeaderSerialization(t *testing.T) {
func BenchmarkSSTableGet(b *testing.B) {
// 创建 Schema
schema := NewSchema("test", []Field{
schema, err := NewSchema("test", []Field{
{Name: "value", Type: FieldTypeInt64},
})
if err != nil {
b.Fatal(err)
}
// 创建测试文件
file, _ := os.Create("bench.sst")