From c4060f7d80fc3d24b9f5f31552a969d41b6b7b00 Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Sun, 28 Feb 2016 11:23:54 -0500 Subject: Make isLower a function for strings not tokens --- names_test.go | 29 ++++++++++++++++++++++++++++- utils.go | 4 ++-- 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 == '{': -- cgit v1.2.3-70-g09d2