This repository was archived by the owner on Jun 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookmarkMove_test.go
More file actions
67 lines (61 loc) · 1.84 KB
/
bookmarkMove_test.go
File metadata and controls
67 lines (61 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package a4webbm
import (
_ "embed"
"testing"
)
var (
//go:embed testdata/move_category_complex_input.txt
moveComplexInput string
//go:embed testdata/move_category_before_expected.txt
moveBeforeExpected string
//go:embed testdata/move_category_newcolumn_expected.txt
moveNewColumnExpected string
//go:embed testdata/move_category_end_expected.txt
moveEndExpected string
//go:embed testdata/move_category_end_lastpage_expected.txt
moveEndLastPageExpected string
)
func TestMoveCategory(t *testing.T) {
tabs := ParseBookmarks(moveComplexInput)
if err := tabs.MoveCategoryBefore(4, 1); err != nil {
t.Fatalf("MoveCategory: %v", err)
}
got := tabs.String()
if got != moveBeforeExpected {
t.Fatalf("expected %q got %q", moveBeforeExpected, got)
}
}
func TestMoveCategoryNewColumn(t *testing.T) {
tabs := ParseBookmarks(moveComplexInput)
if err := tabs.MoveCategoryNewColumn(0, tabs[1].Pages[0], -1); err != nil {
t.Fatalf("MoveCategory: %v", err)
}
got := tabs.String()
if got != moveNewColumnExpected {
t.Fatalf("expected %q got %q", moveNewColumnExpected, got)
}
}
func TestMoveCategoryEndColumn(t *testing.T) {
tabs := ParseBookmarks(moveComplexInput)
if err := tabs.MoveCategoryToEnd(0, tabs[0].Pages[0], 1); err != nil {
t.Fatalf("MoveCategory: %v", err)
}
got := tabs.String()
if got != moveEndExpected {
t.Fatalf("expected %q got %q", moveEndExpected, got)
}
}
func TestMoveCategoryEndLastPage(t *testing.T) {
tabs := ParseBookmarks(moveComplexInput)
destPage := tabs[0].Pages[len(tabs[0].Pages)-1]
lastBlock := destPage.Blocks[len(destPage.Blocks)-1]
destCol := len(lastBlock.Columns) - 1
if err := tabs.MoveCategoryToEnd(0, destPage, destCol); err != nil {
t.Fatalf("MoveCategory: %v", err)
}
got := tabs.String()
expected := moveEndLastPageExpected
if got != expected {
t.Fatalf("expected %q got %q", expected, got)
}
}