diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2017-08-15 01:10:41 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-08-15 01:10:41 +0900 |
commit | 0d171ba1d81886c6f9caf61867129e6daa268cd6 (patch) | |
tree | e82b6b40439ff4f6fc936f31e65790d976ccddb6 /src/chunklist_test.go | |
parent | 2069bbc8b54fa77384e42274ee15af7b397af884 (diff) |
Remove special nilItem
Diffstat (limited to 'src/chunklist_test.go')
-rw-r--r-- | src/chunklist_test.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/chunklist_test.go b/src/chunklist_test.go index 78468e32..c8d33a67 100644 --- a/src/chunklist_test.go +++ b/src/chunklist_test.go @@ -11,10 +11,10 @@ func TestChunkList(t *testing.T) { // FIXME global sortCriteria = []criterion{byScore, byLength} - cl := NewChunkList(func(s []byte, i int) Item { - chars := util.ToChars(s) - chars.Index = int32(i * 2) - return Item{text: chars} + cl := NewChunkList(func(item *Item, s []byte, i int) bool { + item.text = util.ToChars(s) + item.text.Index = int32(i * 2) + return true }) // Snapshot @@ -40,11 +40,13 @@ func TestChunkList(t *testing.T) { // Check the content of the ChunkList chunk1 := snapshot[0] - if len(*chunk1) != 2 { + if chunk1.count != 2 { t.Error("Snapshot should contain only two items") } - if (*chunk1)[0].text.ToString() != "hello" || (*chunk1)[0].Index() != 0 || - (*chunk1)[1].text.ToString() != "world" || (*chunk1)[1].Index() != 2 { + if chunk1.items[0].text.ToString() != "hello" || + chunk1.items[0].Index() != 0 || + chunk1.items[1].text.ToString() != "world" || + chunk1.items[1].Index() != 2 { t.Error("Invalid data") } if chunk1.IsFull() { @@ -67,14 +69,14 @@ func TestChunkList(t *testing.T) { !snapshot[1].IsFull() || snapshot[2].IsFull() || count != chunkSize*2+2 { t.Error("Expected two full chunks and one more chunk") } - if len(*snapshot[2]) != 2 { + if snapshot[2].count != 2 { t.Error("Unexpected number of items") } cl.Push([]byte("hello")) cl.Push([]byte("world")) - lastChunkCount := len(*snapshot[len(snapshot)-1]) + lastChunkCount := snapshot[len(snapshot)-1].count if lastChunkCount != 2 { t.Error("Unexpected number of items:", lastChunkCount) } |