aboutsummaryrefslogtreecommitdiff
path: root/internal/plan/index_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/plan/index_test.go')
-rw-r--r--internal/plan/index_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/plan/index_test.go b/internal/plan/index_test.go
new file mode 100644
index 0000000..b157f56
--- /dev/null
+++ b/internal/plan/index_test.go
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package plan
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestMaxIndex(t *testing.T) {
+ for in, want := range map[string]int{
+ "Work/Acme": 0,
+ "{name}": 0,
+ "{1}": 1,
+ "Work/{2}/{1}": 2,
+ "{stem}-{9}{ext}": 9,
+ "{{1}}": 0,
+ "{mtime:%Y}/{3}-{1}": 3,
+ } {
+ got, err := MaxIndex(in)
+ if err != nil || got != want {
+ t.Errorf("MaxIndex(%q) = %d, %v; want %d", in, got, err, want)
+ }
+ }
+ if _, err := MaxIndex("{name"); err == nil || !strings.Contains(err.Error(), "unclosed placeholder") {
+ t.Errorf("unclosed: %v", err)
+ }
+}