package main import ( "bytes" "testing" ) func TestCountWords(t *testing.T) { b := bytes.NewBufferString("hello world world2 world3 world4\n") exp := 5 res := count(b, false, false) if res != exp { t.Errorf("Expected %d, got %d instead.\n", exp, res) } } func TestCountLines(t *testing.T) { b := bytes.NewBufferString("hello world world2\nworld3\nworld4\n") exp := 3 res := count(b, true, false) if res != exp { t.Errorf("Expected %d, got %d instead.\n", exp, res) } } func TestCountBytes(t *testing.T) { b := bytes.NewBufferString("hello\n") exp := 6 res := count(b, false, true) if res != exp { t.Errorf("Expected %d, got %d instead.\n", exp, res) } }