summaryrefslogtreecommitdiffstats
path: root/utils/markdown/lines_test.go
blob: 78603c5eac28d78f1d29851f73b034725703d596 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package markdown

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestParseLines(t *testing.T) {
	assert.Equal(t, []Line{
		{Range{0, 4}}, {Range{4, 7}},
	}, ParseLines("foo\nbar"))

	assert.Equal(t, []Line{
		{Range{0, 5}}, {Range{5, 8}},
	}, ParseLines("foo\r\nbar"))

	assert.Equal(t, []Line{
		{Range{0, 4}}, {Range{4, 6}}, {Range{6, 9}},
	}, ParseLines("foo\r\r\nbar"))

	assert.Equal(t, []Line{
		{Range{0, 4}},
	}, ParseLines("foo\n"))

	assert.Equal(t, []Line{
		{Range{0, 4}},
	}, ParseLines("foo\r"))

	assert.Equal(t, []Line{
		{Range{0, 5}},
	}, ParseLines("foo\r\n"))
}