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.

csv_test.go 1.3KB

123456789101112131415161718192021222324252627282930
  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. }