Skip to content

Commit 923e4de

Browse files
authored
Merge pull request #11 from dc0d/improve-chunking
improve chunking
2 parents 4c45744 + ea88f58 commit 923e4de

File tree

11 files changed

+43
-10
lines changed

11 files changed

+43
-10
lines changed

.github/workflows/test.yml renamed to .github/workflows/test-main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
47

58
jobs:
69
test:
@@ -10,7 +13,7 @@ jobs:
1013
- name: Install Go
1114
uses: actions/setup-go@v2
1215
with:
13-
go-version: '^1.14'
16+
go-version: '^1.15'
1417

1518
- name: Checkout Code
1619
uses: actions/checkout@v2

.github/workflows/test-pr.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: TestPR
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Install Go
11+
uses: actions/setup-go@v2
12+
with:
13+
go-version: '^1.15'
14+
15+
- name: Checkout Code
16+
uses: actions/checkout@v2
17+
18+
- name: Test
19+
run: go test -count=1 -timeout 30s ./...
20+
21+
- name: Lint
22+
uses: golangci/golangci-lint-action@v2
23+
with:
24+
version: v1.29

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: test
22
test:
33
clear
4-
go test -count=1 -timeout 30s -p 1 -v -cover ./...
4+
go test -count=1 -timeout 30s -cover ./...
55

66
.PHONY: cover
77
cover:

camel_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func Test_ToCamel(t *testing.T) {
2020
{"version 1.21.0", "version1210"},
2121
{"version 1.2.10", "version1210"},
2222
{"PippiLÅNGSTRUMP", "pippiLångstrump"},
23+
{"PippilÅNGSTRUMP", "pippilÅngstrump"},
2324
}
2425

2526
for _, tc := range testCases {

chunk.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package caseconv
22

33
import (
44
"strings"
5+
"unicode"
56
)
67

78
func chunk(str string) []string {
@@ -50,9 +51,9 @@ func (cp *chunkerPredicate) run(r, next rune) (split, drop bool) {
5051

5152
type breakRune rune
5253

53-
func (br breakRune) isLowercase() bool { return br >= 'a' && br <= 'z' }
54-
func (br breakRune) isNumber() bool { return br >= '0' && br <= '9' }
55-
func (br breakRune) isUppercase() bool { return br >= 'A' && br <= 'Z' }
54+
func (br breakRune) isLowercase() bool { return unicode.IsLower(rune(br)) }
55+
func (br breakRune) isNumber() bool { return unicode.IsDigit(rune(br)) }
56+
func (br breakRune) isUppercase() bool { return unicode.IsUpper(rune(br)) }
5657
func (br breakRune) isSplitter() bool {
5758
return br == '_' || br == ' ' || br == '.' || br == '/' || br == '"'
5859
}

chunk_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func Test_chunk(t *testing.T) {
6060
// https://github.com/blakeembrey/change-case/issues/21
6161
{"amazon s3 data", "amazon s3 data"},
6262
{"foo_13_bar", "foo 13 bar"},
63+
{"Pippil ÅNGSTRUMP", "pippil ångstrump"},
6364
}
6465

6566
for _, tc := range testCases {

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/dc0d/caseconv
22

3-
go 1.14
3+
go 1.16
44

5-
require github.com/stretchr/testify v1.6.1
5+
require github.com/stretchr/testify v1.7.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
33
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
44
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
55
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6-
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
7-
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
6+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
7+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
88
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
99
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1010
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

kebab_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func Test_ToKebab(t *testing.T) {
1616
{"Test String", "test-string"},
1717
{"TestV2", "test-v2"},
1818
{"PippiLÅNGSTRUMP", "pippi-långstrump"},
19+
{"PippilÅNGSTRUMP", "pippil-ångstrump"},
1920
}
2021

2122
for _, tc := range testCases {

pascal_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func Test_ToPascal(t *testing.T) {
1919
{"version 1.21.0", "Version1210"},
2020
{"LÅNGSTRUMP", "Långstrump"},
2121
{"PippiLÅNGSTRUMP", "PippiLångstrump"},
22+
{"PippilÅNGSTRUMP", "PippilÅngstrump"},
2223
}
2324

2425
for _, tc := range testCases {

0 commit comments

Comments
 (0)