Add unittests for rule_parser.go
diff --git a/rule_parser_test.go b/rule_parser_test.go
new file mode 100644
index 0000000..4c76c71
--- /dev/null
+++ b/rule_parser_test.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestRuleParser(t *testing.T) {
+ for _, tc := range []struct {
+ in string
+ want Rule
+ } {
+ {
+ in: "foo: bar",
+ want: Rule{
+ outputs: []string{"foo"},
+ inputs: []string{"bar"},
+ },
+ },
+ {
+ in: "foo: bar baz",
+ want: Rule{
+ outputs: []string{"foo"},
+ inputs: []string{"bar", "baz"},
+ },
+ },
+ } {
+ got := &Rule{}
+ got.parse(tc.in)
+ if !reflect.DeepEqual(tc.want, *got) {
+ t.Errorf(`r.parse(%q)=%q, want %q`, tc.in, tc.want, *got)
+ }
+ }
+}