MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / TestHintFileBasicOperations

Function TestHintFileBasicOperations

hintfile_test.go:12–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestHintFileBasicOperations(t *testing.T) {
13 // Test HintEntry encoding and decoding
14 entry := &HintEntry{
15 BucketId: 1,
16 KeySize: 3,
17 ValueSize: 5,
18 Timestamp: 1234567890,
19 TTL: 3600,
20 Flag: DataSetFlag,
21 Status: Committed,
22 Ds: DataStructureBTree,
23 DataPos: 100,
24 FileID: 1,
25 Key: []byte("key"),
26 }
27
28 // Test encoding
29 encoded := entry.Encode()
30 if len(encoded) == 0 {
31 t.Fatal("Failed to encode hint entry")
32 }
33
34 // Test decoding
35 decoded := &HintEntry{}
36 err := decoded.Decode(encoded)
37 if err != nil {
38 t.Fatalf("Failed to decode hint entry: %v", err)
39 }
40
41 // Verify decoded values
42 if decoded.BucketId != entry.BucketId {
43 t.Errorf("Expected BucketId %d, got %d", entry.BucketId, decoded.BucketId)
44 }
45 if decoded.KeySize != entry.KeySize {
46 t.Errorf("Expected KeySize %d, got %d", entry.KeySize, decoded.KeySize)
47 }
48 if decoded.ValueSize != entry.ValueSize {
49 t.Errorf("Expected ValueSize %d, got %d", entry.ValueSize, decoded.ValueSize)
50 }
51 if decoded.Timestamp != entry.Timestamp {
52 t.Errorf("Expected Timestamp %d, got %d", entry.Timestamp, decoded.Timestamp)
53 }
54 if decoded.TTL != entry.TTL {
55 t.Errorf("Expected TTL %d, got %d", entry.TTL, decoded.TTL)
56 }
57 if decoded.Flag != entry.Flag {
58 t.Errorf("Expected Flag %d, got %d", entry.Flag, decoded.Flag)
59 }
60 if decoded.Status != entry.Status {
61 t.Errorf("Expected Status %d, got %d", entry.Status, decoded.Status)
62 }
63 if decoded.Ds != entry.Ds {
64 t.Errorf("Expected Ds %d, got %d", entry.Ds, decoded.Ds)
65 }
66 if decoded.DataPos != entry.DataPos {
67 t.Errorf("Expected DataPos %d, got %d", entry.DataPos, decoded.DataPos)
68 }
69 if decoded.FileID != entry.FileID {

Callers

nothing calls this directly

Calls 2

EncodeMethod · 0.95
DecodeMethod · 0.95

Tested by

no test coverage detected