-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexecCamelCase_test.go
89 lines (70 loc) · 2.67 KB
/
execCamelCase_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestExecCamelCase(t *testing.T) {
file, err := createFile("test_exec_camel_case.go")
require.NoError(t, err)
require.NoError(t, execCamelCase(file.Name()))
require.NoError(t, checkFileAndRemove("testExecCamelCase.go"))
}
func TestExecCamelCaseInFolder(t *testing.T) {
fn, err := createNestedFoldersWithFiles("TestExecCamelCaseInFolder", "snake_case.cpp", 1)
require.NoError(t, err)
defer removeNestedFolder("TestExecCamelCaseInFolder")
require.NoError(t, execCamelCase(fn))
require.NoError(t, checkFileInNestedFolder("TestExecCamelCaseInFolder", "snakeCase.cpp"))
}
func TestExecCamelCaseAllFolder(t *testing.T) {
fn, err := createNestedFoldersWithFiles("TestExecCamelCaseAllFolder", "snake_case.cpp", 10)
require.NoError(t, err)
defer removeNestedFolder("TestExecCamelCaseAllFolder")
require.NoError(t, execCamelCase(fn))
require.NoError(t, checkFileInNestedFolder("TestExecCamelCaseAllFolder", "snakeCase.cpp"))
}
func TestExecCamelCaseFileWithSpace(t *testing.T) {
fn, err := createNestedFoldersWithFiles("TestExecCamelCaseFileWithSpace", "name with spaces.go", 1)
require.NoError(t, err)
defer removeNestedFolder("TestExecCamelCaseFileWithSpace")
require.NoError(t, execCamelCase(fn))
require.NoError(t, checkFileInNestedFolder("TestExecCamelCaseFileWithSpace", "nameWithSpaces.go"))
}
func TestExecCamelCaseFileWithCapitalLetter(t *testing.T) {
fn, err := createNestedFoldersWithFiles("TestExecCamelCaseFileWithCapitalLetter", "CapitalLetterName.go", 1)
require.NoError(t, err)
defer removeNestedFolder("TestExecCamelCaseFileWithCapitalLetter")
require.NoError(t, execCamelCase(fn))
require.NoError(t, checkFileInNestedFolder("TestExecCamelCaseFileWithCapitalLetter", "capitalLetterName.go"))
}
func TestExecCamelCaseError(t *testing.T) {
require.Error(t, execCamelCase(""))
}
func BenchmarkExecCamelCaseOneFile(b *testing.B) {
for i := 0; i < b.N; i++ {
file, _ := createFile("camel_case.cpp")
_ = execCamelCase(file.Name())
_ = checkFileAndRemove("camelCase.cpp")
}
}
func BenchmarkExecCamelCaseDir(b *testing.B) {
for i := 0; i < b.N; i++ {
fn, _ := createNestedFoldersWithFiles("folder", "camel_case.cpp", 10)
_ = execCamelCase(fn)
removeNestedFolder("folder")
}
}
func BenchmarkExecCamelCaseLotDir(b *testing.B) {
for i := 0; i < b.N; i++ {
fn, _ := createNestedFoldersWithFiles("folder", "camel_case.cpp", 100)
_ = execCamelCase(fn)
removeNestedFolder("folder")
}
}
func BenchmarkExecCamelCaseManyDir(b *testing.B) {
for i := 0; i < b.N; i++ {
fn, _ := createNestedFoldersWithFiles("folder", "camel_case.cpp", 1000)
_ = execCamelCase(fn)
removeNestedFolder("folder")
}
}