markdown_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. package discord
  2. import "testing"
  3. func TestParseMarkdown(t *testing.T) {
  4. tests := []struct {
  5. name string
  6. in string
  7. want string
  8. }{
  9. {"bold", "**test**", "[::b]test[::-]"},
  10. {"italic", "*test*", "[::i]test[::-]"},
  11. {"underline", "__test__", "[::u]test[::-]"},
  12. {"strikethrough", "~~test~~", "[::s]test[::-]"},
  13. }
  14. for _, test := range tests {
  15. t.Run(test.name, func(t *testing.T) {
  16. if got := ParseMarkdown(test.in); got != test.want {
  17. t.Errorf("got: %s\nwant: %s", got, test.want)
  18. }
  19. })
  20. }
  21. }
  22. func BenchmarkParseMarkdown(b *testing.B) {
  23. 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.~~
  24. 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.`
  25. for i := 0; i < b.N; i++ {
  26. ParseMarkdown(in)
  27. }
  28. }