本站源代码
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

31 linhas
1.3KB

  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package markup
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestRenderCSV(t *testing.T) {
  10. var parser Parser
  11. var kases = map[string]string{
  12. "a": "<table class=\"table\"><tr><td>a</td></tr></table>",
  13. "1,2": "<table class=\"table\"><tr><td>1</td><td>2</td></tr></table>",
  14. "1;2": "<table class=\"table\"><tr><td>1</td><td>2</td></tr></table>",
  15. "1\t2": "<table class=\"table\"><tr><td>1</td><td>2</td></tr></table>",
  16. "1|2": "<table class=\"table\"><tr><td>1</td><td>2</td></tr></table>",
  17. "1,2,3;4,5,6;7,8,9\na;b;c": "<table class=\"table\"><tr><td>1,2,3</td><td>4,5,6</td><td>7,8,9</td></tr><tr><td>a</td><td>b</td><td>c</td></tr></table>",
  18. "\"1,2,3,4\";\"a\nb\"\nc;d": "<table class=\"table\"><tr><td>1,2,3,4</td><td>a\nb</td></tr><tr><td>c</td><td>d</td></tr></table>",
  19. "<br/>": "<table class=\"table\"><tr><td>&lt;br/&gt;</td></tr></table>",
  20. }
  21. for k, v := range kases {
  22. res := parser.Render([]byte(k), "", nil, false)
  23. assert.EqualValues(t, v, string(res))
  24. }
  25. }
上海开阖软件有限公司 沪ICP备12045867号-1