forked from Cloudxtreme/wiki-9
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils_test.go
73 lines (64 loc) · 2.45 KB
/
utils_test.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"testing"
)
func TestAutoCamelCase(t *testing.T) {
checks := []struct {
in string
out string
}{
{"WhatEver", "[WhatEver](/view/WhatEver)"},
{"/WhatEver/", "/WhatEver/"},
{"What/Ever", "What/Ever"},
{"What/EverEver", "[What/EverEver](/view/What/EverEver)"},
{"WhatEver, WhenEver", "[WhatEver](/view/WhatEver), [WhenEver](/view/WhenEver)"},
{"WhatEver! WhenEver", "[WhatEver](/view/WhatEver)! [WhenEver](/view/WhenEver)"},
{"WhatEver? WhenEver", "[WhatEver](/view/WhatEver)? [WhenEver](/view/WhenEver)"},
{"WhatEver% WhenEver", "[WhatEver](/view/WhatEver)% [WhenEver](/view/WhenEver)"},
{"WhatEver& WhenEver", "[WhatEver](/view/WhatEver)& [WhenEver](/view/WhenEver)"},
{"WhatEver/WhenEver", "[WhatEver/WhenEver](/view/WhatEver/WhenEver)"},
{"WhatEver/ WhenEver", "WhatEver/ [WhenEver](/view/WhenEver)"},
{"WhatEver / WhenEver", "[WhatEver](/view/WhatEver) / [WhenEver](/view/WhenEver)"},
{"fobar WhatEver bla", "fobar [WhatEver](/view/WhatEver) bla"},
{" - [OpenBSD Router : Native IPv6](https://lipidity.com/openbsd/router/) ",
" - [OpenBSD Router : Native IPv6](https://lipidity.com/openbsd/router/) "},
{" Another example [Quickstart code](/view/GoLang/QuickStart), doh ",
" Another example [Quickstart code](/view/GoLang/QuickStart), doh "},
{"Foo/WhatEver", "[Foo/WhatEver](/view/Foo/WhatEver)"},
{"FooBar/WhatEver", "[FooBar/WhatEver](/view/FooBar/WhatEver)"},
{"Foo/Bar/What/Ever", "Foo/Bar/What/Ever"},
{`# Dishes
- [Three Bean Salad](Food/ThreeBeanSalad)
- [Twelve Marinades](Food/TwelveMarinades)
- [Greek Lentil Salad](Food/GreekLentilSalad)`, `# Dishes
- [Three Bean Salad](Food/ThreeBeanSalad)
- [Twelve Marinades](Food/TwelveMarinades)
- [Greek Lentil Salad](Food/GreekLentilSalad)`,
},
}
for _, check := range checks {
out := AutoCamelCase([]byte(check.in), "/view/")
if string(out) != check.out {
t.Errorf("mismatch:\n got:<%s>\n !=\n want:<%s>", out, check.out)
}
}
}
func TestCleanNewlines(t *testing.T) {
checks := []struct {
in string
out string
}{
{"foo\r\nbar\r\nbaz\r\n", "foo\nbar\nbaz\n"},
{"foo\rbar\rbaz\r", "foo\nbar\nbaz\n"},
{"foo\nbar\nbaz\n", "foo\nbar\nbaz\n"},
{"foo\nbar\nbaz", "foo\nbar\nbaz\n"},
{"foo\r\nbar\nbaz\r", "foo\nbar\nbaz\n"},
{"foo\nbar\rbaz\n\n", "foo\nbar\nbaz\n\n"},
}
for _, check := range checks {
out := CleanNewlines(check.in)
if string(out) != check.out {
t.Errorf("mismatch:\n <%s>\n !=\n <%s>", out, check.out)
}
}
}