util.go 411 B

1234567891011121314151617181920
  1. package util
  2. import (
  3. "testing"
  4. "github.com/muesli/reflow/wordwrap"
  5. "github.com/muesli/reflow/wrap"
  6. )
  7. func AssertEqual(expected string, output string, t *testing.T) {
  8. if expected != output {
  9. t.Fatalf("Expected `%s` not `%s`\n", expected, output)
  10. }
  11. }
  12. func Wrap(text string, width int) string {
  13. if width < 1 {
  14. width = 1
  15. }
  16. return wrap.String(wordwrap.String(text, width), width)
  17. }