main_test.go 253 B

1234567891011121314151617
  1. package main
  2. import (
  3. "bytes"
  4. "testing"
  5. )
  6. func TestCountWords(t *testing.T) {
  7. b := bytes.NewBufferString("hello world world2 world3 world4\n")
  8. exp := 5
  9. res := count(b)
  10. if res != exp {
  11. t.Errorf("Expected %d, got %d instead.\n", exp, res)
  12. }
  13. }