A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

44 строки
1.2 KiB

  1. /*
  2. * Copyright © 2021 Musing Studio LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. package writefreely
  11. import "testing"
  12. func TestApplyBasicMarkdown(t *testing.T) {
  13. tests := []struct {
  14. name string
  15. in string
  16. result string
  17. }{
  18. {"empty", "", ""},
  19. {"empty spaces", " ", ""},
  20. {"empty tabs", "\t", ""},
  21. {"empty newline", "\n", ""},
  22. {"nums", "123", "123"},
  23. {"dot", ".", "."},
  24. {"dash", "-", "-"},
  25. {"plain", "Hello, World!", "Hello, World!"},
  26. {"multibyte", "こんにちは", `こんにちは`},
  27. {"bold", "**안녕하세요**", `<strong>안녕하세요</strong>`},
  28. {"link", "[WriteFreely](https://writefreely.org)", `<a href="https://writefreely.org" rel="nofollow">WriteFreely</a>`},
  29. {"date", "12. April", `12. April`},
  30. {"table", "| Hi | There |", `| Hi | There |`},
  31. }
  32. for _, test := range tests {
  33. t.Run(test.name, func(t *testing.T) {
  34. res := applyBasicMarkdown([]byte(test.in))
  35. if res != test.result {
  36. t.Errorf("%s: wanted %s, got %s", test.name, test.result, res)
  37. }
  38. })
  39. }
  40. }