File: title_test.go

package info (click to toggle)
golang-github-jdkato-prose 1.1.0%2Bgit20171031.e27abfd-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,848 kB
  • sloc: python: 115; makefile: 55; sh: 21
file content (39 lines) | stat: -rw-r--r-- 824 bytes parent folder | download | duplicates (3)
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
package transform

import (
	"encoding/json"
	"path/filepath"
	"testing"

	"github.com/jdkato/prose/internal/util"
	"github.com/stretchr/testify/assert"
)

type testCase struct {
	Input  string
	Expect string
}

func TestTitle(t *testing.T) {
	tests := make([]testCase, 0)
	cases := util.ReadDataFile(filepath.Join(testdata, "title.json"))

	util.CheckError(json.Unmarshal(cases, &tests))
	tc := NewTitleConverter(APStyle)
	for _, test := range tests {
		assert.Equal(t, test.Expect, tc.Title(test.Input))
	}
}

func BenchmarkTitle(b *testing.B) {
	tests := make([]testCase, 0)
	cases := util.ReadDataFile(filepath.Join(testdata, "title.json"))

	util.CheckError(json.Unmarshal(cases, &tests))
	tc := NewTitleConverter(APStyle)
	for n := 0; n < b.N; n++ {
		for _, test := range tests {
			_ = tc.Title(test.Input)
		}
	}
}