ui_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package util
  2. import (
  3. "testing"
  4. )
  5. func TestParseMarkdown(t *testing.T) {
  6. tests := []struct {
  7. name string
  8. in string
  9. want string
  10. }{
  11. {"bold", "**test**", "[::b]test[::-]"},
  12. {"italic", "*test*", "[::i]test[::-]"},
  13. {"underline", "__test__", "[::u]test[::-]"},
  14. {"strikethrough", "~~test~~", "[::s]test[::-]"},
  15. }
  16. for _, test := range tests {
  17. t.Run(test.name, func(t *testing.T) {
  18. if got := ParseMarkdown(test.in); got != test.want {
  19. t.Errorf("got: %s\nwant: %s", got, test.want)
  20. }
  21. })
  22. }
  23. }
  24. func BenchmarkParseMarkdown(b *testing.B) {
  25. in := `**Porro mollitia aut odio dolor rerum.** Saepe qui aut reiciendis illo nisi. Id illo et quo consequatur sint labore placeat maiores. __Commodi odio quae reprehenderit.__ Beatae illum est fugiat ut architecto itaque eveniet aut. ~~Consequuntur quas explicabo et impedit eum porro facere et.~~
  26. Sit commodi sed iure et sed quae eveniet. *Sit non distinctio nihil sunt. Nesciunt cumque aspernatur *nulla* porro et earum quidem.* Sed omnis at commodi vel quasi. Fuga et **consequatur** molestias dicta vel provident et aspernatur. Dolorem molestias ipsa aut ~~facilis quae dolorem~~ eveniet dicta.`
  27. for i := 0; i < b.N; i++ {
  28. ParseMarkdown(in)
  29. }
  30. }