diff options
| author | Grant Ammons <gammons@gmail.com> | 2016-04-23 16:59:52 -0400 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2016-04-23 16:59:52 -0400 |
| commit | 8138ffaf380fb646b6877dd20f874735eddd2d6d (patch) | |
| tree | da3077b68ff432d4ffe2aeae234ecb70843a3165 /parser_test.go | |
Initial commit
Diffstat (limited to 'parser_test.go')
| -rw-r--r-- | parser_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/parser_test.go b/parser_test.go new file mode 100644 index 0000000..9e1c9cf --- /dev/null +++ b/parser_test.go @@ -0,0 +1,33 @@ +package todolist + +import "testing" + +func TestParseSubject(t *testing.T) { + parser := &Parser{} + todo := parser.Parse("do this thing") + if todo.Subject != "do this thing" { + t.Error("Expected todo.Subject to equal 'do this thing'") + } +} + +func TestParseSubjectWithDue(t *testing.T) { + parser := &Parser{} + todo := parser.Parse("do this thing due tomorrow") + if todo.Subject != "do this thing" { + t.Error("Expected todo.Subject to equal 'do this thing', got ", todo.Subject) + } +} + +func TestParseProjects(t *testing.T) { + parser := &Parser{} + todo := parser.Parse("do this thing +proj1 +proj2 due tomorrow") + if len(todo.Projects) != 2 { + t.Error("Expected Projects length to be 2") + } + if todo.Projects[0] != "proj1" { + t.Error("todo.Projects[0] should equal 'proj1' but got", todo.Projects[0]) + } + if todo.Projects[1] != "proj2" { + t.Error("todo.Projects[1] should equal 'proj2' but got", todo.Projects[1]) + } +} |
