A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

56 lines
3.3 KiB

  1. /*
  2. * Copyright © 2018 A Bunch Tell 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 parse
  11. import "testing"
  12. func TestPostLede(t *testing.T) {
  13. text := map[string]string{
  14. "早安。跨出舒適圈,才能前往": "早安。",
  15. "早安。This is my post. It is great.": "早安。",
  16. "Hello. 早安。": "Hello.",
  17. "Sup? Everyone says punctuation is punctuation.": "Sup?",
  18. "Humans are humans, and society is full of good and bad actors. Technology, at the most fundamental level, is a neutral tool that can be used by either to meet any ends. ": "Humans are humans, and society is full of good and bad actors.",
  19. `Online Domino Is Must For Everyone
  20. Do you want to understand how to play poker online?`: "Online Domino Is Must For Everyone",
  21. `おはようございます
  22. 私は日本から帰ったばかりです。`: "おはようございます",
  23. "Hello, we say, おはよう. We say \"good morning\"": "Hello, we say, おはよう.",
  24. }
  25. c := 1
  26. for i, o := range text {
  27. if s := PostLede(i, true); s != o {
  28. t.Errorf("#%d: Got '%s' from '%s'; expected '%s'", c, s, i, o)
  29. }
  30. c++
  31. }
  32. }
  33. func TestTruncToWord(t *testing.T) {
  34. text := map[string]string{
  35. "Можливо, ми можемо використовувати інтернет-інструменти, щоб виготовити якийсь текст, який би міг бути і на, і в кінцевому підсумку, буде скорочено, тому що це тривало так довго.": "Можливо, ми можемо використовувати інтернет-інструменти, щоб виготовити якийсь",
  36. "早安。This is my post. It is great. It is a long post that is great that is a post that is great.": "早安。This is my post. It is great. It is a long post that is great that is a post",
  37. "Sup? Everyone says punctuation is punctuation.": "Sup? Everyone says punctuation is punctuation.",
  38. "I arrived in Japan six days ago. Tired from a 10-hour flight after a night-long layover in Calgary, I wandered wide-eyed around Narita airport looking for an ATM.": "I arrived in Japan six days ago. Tired from a 10-hour flight after a night-long",
  39. }
  40. c := 1
  41. for i, o := range text {
  42. if s, _ := TruncToWord(i, 80); s != o {
  43. t.Errorf("#%d: Got '%s' from '%s'; expected '%s'", c, s, i, o)
  44. }
  45. c++
  46. }
  47. }