func testiter2(t *testing.T, s Storer) { err := s.Tx(true, func(tx Transaction) error { var err error out := make(rand.StringPermutation, len(rand.LowerCase)) err = rand.RandomPermutation(rand.StringPermutation(rand.LowerCase), out, "go") if err != nil { return nil } for i, key := range out { err = tx.Put(key, &TestStruct{I: i, Key: key}) if err != nil { return err } } c := tx.Cursor() prev, _ := c.First() for k, _ := c.First(); k != ""; k, _ = c.Next() { if k < prev { t.Logf("not in alphabetic sequence %v >= %v", prev, k) t.Fail() } prev = k } return nil }) if err != nil { t.Fatal(e.Trace(e.Forward(err))) } }
func testsort(t *testing.T, s Storer) { for i := 0; i < 50; i++ { err := s.Tx(true, func(tx Transaction) error { var err error out := make(rand.StringPermutation, len(rand.LowerCase)) err = rand.RandomPermutation(rand.StringPermutation(rand.LowerCase), out, "go") if err != nil { return nil } //t.Log(out) for i, key := range out { err = tx.Put(key, &TestStruct{I: i, Key: key}) if err != nil { return err } } //var l uint // l, err = tx.Len() // if err != nil { // return err // } // if l != uint(len(out)) { // return e.New("wrong len %v", l) // } c := tx.Cursor() prev, _ := c.First() for k, _ := c.First(); k != ""; k, _ = c.Next() { if k < prev { t.Log("not in alphabetic sequence") t.Fail() } // err := c.Del() // if err != nil { // return err // } } return nil }) if err != nil { t.Fatal(e.Trace(e.Forward(err))) } err = s.Drop() if err != nil { t.Fatal(e.Trace(e.Forward(err))) } } }