Skip to content

Commit

Permalink
focus
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed Mar 7, 2024
1 parent 9321311 commit 9053339
Showing 1 changed file with 44 additions and 27 deletions.
71 changes: 44 additions & 27 deletions mdbx/cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,31 +730,12 @@ func TestCursor_Del(t *testing.T) {
}
}

func TestDupCursor_EmptyKeyValues2(t *testing.T) {
env, err := NewEnv()
if err != nil {
t.Fatalf("env: %s", err)
}
path := t.TempDir()
err = env.SetOption(OptMaxDB, 1024)
if err != nil {
t.Fatalf("setmaxdbs: %v", err)
}
const pageSize = 4096
err = env.SetGeometry(-1, -1, 64*1024*pageSize, -1, -1, pageSize)
if err != nil {
t.Fatalf("setmaxdbs: %v", err)
}
err = env.Open(path, 0, 0664)
if err != nil {
t.Fatalf("open: %s", err)
}
t.Cleanup(func() {
env.Close()
})
func TestDupCursor_EmptyKeyValues1(t *testing.T) {
env, _ := setup(t)

err = env.Update(func(txn *Txn) (err error) {
db, err := txn.OpenDBI("testingdup", Create|DupSort, nil, nil)
var db DBI
err := env.Update(func(txn *Txn) (err error) {
db, err = txn.OpenDBI("testingdup", Create|DupSort, nil, nil)
if err != nil {
return err
}
Expand All @@ -779,15 +760,51 @@ func TestDupCursor_EmptyKeyValues2(t *testing.T) {
if !bytes.Equal(v, []byte{}) {
panic(v)
}
_, v, err = cur.Get([]byte{1}, []byte{0}, GetBothRange)
if err != nil {
panic(err)
}
if !bytes.Equal(v, []byte{8}) {
panic(v)
}
_, v, err = cur.Get([]byte{}, []byte{0}, GetBoth)
if err == nil {
panic("expecting 'not found' error")
}
if v != nil {
panic(v)
}

// can use empty key as valid key in non-dupsort operations
k, v, err := cur.Get([]byte{}, nil, SetRange)
if err != nil {
panic(err)
}
if k == nil {
panic("nil")
}
if !bytes.Equal(k, []byte{1}) {
panic(fmt.Sprintf("%x", k))
}
if !bytes.Equal(v, []byte{}) {
panic(fmt.Sprintf("%x", v))
}
k, v, err = cur.Get([]byte{}, nil, Set)
if err == nil {
panic("expected 'not found' error")
}
if k != nil {
panic("nil")
}

return nil
})
if err != nil {
panic(err)
t.Error(err)
}
}

func TestDupCursor_EmptyKeyValues(t *testing.T) {
t.Skip()
func TestDupCursor_EmptyKeyValues2(t *testing.T) {
env, _ := setup(t)

var db DBI
Expand Down

0 comments on commit 9053339

Please sign in to comment.