add stack test and take new stack

This commit is contained in:
sentriz
2019-06-28 14:26:10 +01:00
parent a4377fc425
commit fb99ecc84e
2 changed files with 55 additions and 20 deletions

40
scanner/stack_test.go Normal file
View File

@@ -0,0 +1,40 @@
package scanner
import (
"testing"
"github.com/sentriz/gonic/model"
)
func testAlbum(id int) *model.Album {
return &model.Album{IDBase: model.IDBase{id}}
}
func TestFolderStack(t *testing.T) {
expected := "[6, 5, 4, root]"
//
sta := &folderStack{}
sta.push(testAlbum(3))
sta.push(testAlbum(4))
sta.push(testAlbum(5))
sta.push(testAlbum(6))
actual := sta.string()
if expected != actual {
t.Errorf("first stack: expected string %q, got %q",
expected, actual)
}
//
sta = &folderStack{}
sta.push(testAlbum(3))
sta.push(testAlbum(4))
sta.peek()
sta.push(testAlbum(5))
sta.push(testAlbum(6))
sta.push(testAlbum(7))
sta.pop()
actual = sta.string()
if expected != actual {
t.Errorf("second stack: expected string %q, got %q",
expected, actual)
}
}