summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--names_test.go29
-rw-r--r--utils.go4
2 files changed, 30 insertions, 3 deletions
diff --git a/names_test.go b/names_test.go
index 0cc97a0..ad8ba05 100644
--- a/names_test.go
+++ b/names_test.go
@@ -93,7 +93,34 @@ func TestLength(t *testing.T) {
for _, test := range tests {
actual := length(test.s)
if test.expected != actual {
- t.Errorf("Expected: %d, actual: %d", test.expected, actual)
+ t.Errorf("%s, expected: %d, actual: %d", test.s,
+ test.expected, actual)
+ }
+ }
+}
+
+func TestIsLower(t *testing.T) {
+ tests := []struct {
+ s string
+ expected bool
+ }{
+ {"", false},
+ {"abc", true},
+ {"Abc", false},
+ {"a{bc}", true},
+ {"A{bc}", false},
+ {"{a}A", false},
+ {"{A}a", true},
+ {"{\\i B}A", true},
+ {"{\\AA a}a", false},
+ {"{abc}A", false},
+ {"{Abc}a", true},
+ }
+ for _, test := range tests {
+ actual := isLower(test.s)
+ if test.expected != actual {
+ t.Errorf("%s, expected: %t, actual: %t", test.s,
+ test.expected, actual)
}
}
}
diff --git a/utils.go b/utils.go
index 1ca8298..e91ae44 100644
--- a/utils.go
+++ b/utils.go
@@ -121,8 +121,8 @@ func (r *reader) readCommand() string {
return buf.String()
}
-func (t *Token) isLower() bool {
- reader := newReader(t.Text)
+func isLower(s string) bool {
+ reader := newReader(s)
for c := reader.readRune(); c != eof; c = reader.readRune() {
switch {
case c == '{':