github.com/cayleygraph/cayley@v0.7.7/graph/kv/btree/btree_test.go (about)

     1  // Copyright 2017 The Cayley Authors. All rights reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package btree
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/cayleygraph/cayley/graph"
    21  	"github.com/cayleygraph/cayley/graph/kv/kvtest"
    22  	hkv "github.com/hidal-go/hidalgo/kv"
    23  	"github.com/hidal-go/hidalgo/kv/kvdebug"
    24  )
    25  
    26  const debug = false
    27  
    28  func makeBtree(t testing.TB) (hkv.KV, graph.Options, func()) {
    29  	if debug {
    30  		return makeBtreeDebug(t)
    31  	}
    32  	return New(), nil, func() {}
    33  }
    34  
    35  func makeBtreeDebug(t testing.TB) (hkv.KV, graph.Options, func()) {
    36  	db := New()
    37  	d := kvdebug.New(db)
    38  	d.Log(true)
    39  	return d, nil, func() {
    40  		d.Close()
    41  		t.Logf("kv stats: %+v", d.Stats())
    42  	}
    43  }
    44  
    45  var conf = &kvtest.Config{
    46  	AlwaysRunIntegration: true,
    47  }
    48  
    49  func TestBtree(t *testing.T) {
    50  	kvtest.TestAll(t, makeBtree, conf)
    51  }
    52  
    53  func BenchmarkBtree(b *testing.B) {
    54  	kvtest.BenchmarkAll(b, makeBtree, conf)
    55  }