File: normalize_test.go

package info (click to toggle)
golang-github-go-enry-go-license-detector 4.3.0%2Bgit20221007.a3a1cc6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,068 kB
  • sloc: makefile: 25
file content (31 lines) | stat: -rw-r--r-- 963 bytes parent folder | download
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
package normalize

import (
	"testing"

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

func TestNormalizeLines(t *testing.T) {
	tt := []struct {
		name    string
		in, out string
	}{
		{"lines", "a\r\nb\rc\n\r", "a\nb\nc\n"},
		{"whitespace", "   a\n b\nc    \n", "a\nb\nc\n"},
		{"quotes lowercase",
			`“You” (or “Your”) shall mean an individual or Legal Entity exercising
			permissions granted by this License.`,
			`"you" (or "your") shall mean an individual or legal entity exercising
permissions granted by this license.`},
		{"normalize links", "A <https://fsf.org/> B", "a https:/fsf.org/ b"},
		{"license", "license.\n\nlicence\n\n", "license\n\nlicense\n\n"},
		{"punctuation", "a-‒–—―⁓⸺⸻~˗‐‑⁃⁻₋−∼⎯⏤─➖𐆑֊﹘﹣-", "a-"},
		{"bullet", "-\n*\n✱\n﹡\n•\n●\n⚫\n⏺\n🞄\n∙\n⋅\n", ""},
		{"license", "", ""},
	}

	for _, tc := range tt {
		assert.Equal(t, tc.out, LicenseText(tc.in, Enforced))
	}
}