github.com/lazin/go-ngram@v0.0.0-20160527144230-80eaf16ac4eb/spool_test.go (about)

     1  package ngram
     2  
     3  import "testing"
     4  
     5  func Test_spool(t *testing.T) {
     6  	var spool stringPool
     7  	ix0, err := spool.Append("foo")
     8  	if err != nil {
     9  		t.Error(err)
    10  	}
    11  	ix1, err := spool.Append("bar")
    12  	if err != nil {
    13  		t.Error(err)
    14  	}
    15  	st0, err := spool.ReadAt(ix0)
    16  	if err != nil {
    17  		t.Error(err)
    18  	}
    19  	if st0 != "foo" {
    20  		t.Error("Can't read 'foo'")
    21  	}
    22  	st1, err := spool.ReadAt(ix1)
    23  	if err != nil {
    24  		t.Error(err)
    25  	}
    26  	if st1 != "bar" {
    27  		t.Error("Can't read 'bar'")
    28  	}
    29  }