Refactor kafka to pure Go (franz-go), fix DBC stubs, update Dockerfile
This commit is contained in:
17
pkg/can-go/internal/identifiers/case.go
Normal file
17
pkg/can-go/internal/identifiers/case.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package identifiers
|
||||
|
||||
import "unicode"
|
||||
|
||||
func IsCamelCase(s string) bool {
|
||||
i := 0
|
||||
for _, r := range s {
|
||||
if unicode.IsDigit(r) {
|
||||
continue
|
||||
}
|
||||
if i == 0 && !unicode.IsUpper(r) || !IsAlphaChar(r) && !IsNumChar(r) {
|
||||
return false
|
||||
}
|
||||
i++
|
||||
}
|
||||
return true
|
||||
}
|
||||
18
pkg/can-go/internal/identifiers/case_test.go
Normal file
18
pkg/can-go/internal/identifiers/case_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package identifiers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func TestIsCamelCase(t *testing.T) {
|
||||
assert.Assert(t, IsCamelCase("SOC"))
|
||||
assert.Assert(t, IsCamelCase("Camel"))
|
||||
assert.Assert(t, IsCamelCase("CamelCase"))
|
||||
assert.Assert(t, IsCamelCase("111CamelCaseNr"))
|
||||
assert.Assert(t, !IsCamelCase("camelCase"))
|
||||
assert.Assert(t, !IsCamelCase("snake_case"))
|
||||
assert.Assert(t, !IsCamelCase("kebab-case"))
|
||||
assert.Assert(t, !IsCamelCase("111camelCaseNr"))
|
||||
}
|
||||
9
pkg/can-go/internal/identifiers/char.go
Normal file
9
pkg/can-go/internal/identifiers/char.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package identifiers
|
||||
|
||||
func IsAlphaChar(r rune) bool {
|
||||
return ('A' <= r && r <= 'Z') || ('a' <= r && r <= 'z')
|
||||
}
|
||||
|
||||
func IsNumChar(r rune) bool {
|
||||
return '0' <= r && r <= '9'
|
||||
}
|
||||
23
pkg/can-go/internal/identifiers/char_test.go
Normal file
23
pkg/can-go/internal/identifiers/char_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package identifiers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func TestIsAlphaChar(t *testing.T) {
|
||||
assert.Assert(t, IsAlphaChar('b'))
|
||||
assert.Assert(t, IsAlphaChar('C'))
|
||||
assert.Assert(t, !IsAlphaChar('Ö'))
|
||||
assert.Assert(t, !IsAlphaChar('_'))
|
||||
}
|
||||
|
||||
func TestIsNumChar(t *testing.T) {
|
||||
assert.Assert(t, IsNumChar('0'))
|
||||
assert.Assert(t, IsNumChar('1'))
|
||||
assert.Assert(t, IsNumChar('2'))
|
||||
assert.Assert(t, IsNumChar('9'))
|
||||
assert.Assert(t, !IsNumChar('/'))
|
||||
assert.Assert(t, !IsNumChar('a'))
|
||||
}
|
||||
Reference in New Issue
Block a user