Renamed 'fromSnakeCase' to 'toCamelCase'
This commit is contained in:
@@ -18,7 +18,7 @@ proc toSnakeCase*(str: string): string =
|
|||||||
result.add '_'
|
result.add '_'
|
||||||
prv = ch
|
prv = ch
|
||||||
|
|
||||||
proc fromSnakeCase*(str: string): string =
|
proc toCamelCase*(str: string): string =
|
||||||
## Convert from SNAKE_CASE to camelCase
|
## Convert from SNAKE_CASE to camelCase
|
||||||
var usc: bool = false
|
var usc: bool = false
|
||||||
for ch in str:
|
for ch in str:
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
# To run these tests, simply execute `nimble test`.
|
|
||||||
import unittest
|
|
||||||
import snake_case
|
|
||||||
|
|
||||||
test "fromSnakeCase":
|
|
||||||
check "TO_SNAKE_CASE".fromSnakeCase() == "toSnakeCase"
|
|
||||||
check "HTTP_SERVER_NAME".fromSnakeCase() == "httpServerName"
|
|
||||||
check "PORT_NUM".fromSnakeCase() == "portNum"
|
|
||||||
check "FIRST_NAME_ONLY".fromSnakeCase() == "firstNameOnly"
|
|
||||||
check "ROSTR_TOKEN".fromSnakeCase() == "rostrToken"
|
|
||||||
|
|
||||||
test "all lowercase":
|
|
||||||
check "thisisatest".fromSnakeCase() == "thisisatest"
|
|
||||||
|
|
||||||
test "all uppercase":
|
|
||||||
check "THISISATEST".fromSnakeCase() == "thisisatest"
|
|
||||||
16
tests/test2_toCamelCase.nim
Normal file
16
tests/test2_toCamelCase.nim
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# To run these tests, simply execute `nimble test`.
|
||||||
|
import unittest
|
||||||
|
import snake_case
|
||||||
|
|
||||||
|
test "toCamelCase":
|
||||||
|
check "TO_SNAKE_CASE".toCamelCase() == "toSnakeCase"
|
||||||
|
check "HTTP_SERVER_NAME".toCamelCase() == "httpServerName"
|
||||||
|
check "PORT_NUM".toCamelCase() == "portNum"
|
||||||
|
check "FIRST_NAME_ONLY".toCamelCase() == "firstNameOnly"
|
||||||
|
check "ROSTR_TOKEN".toCamelCase() == "rostrToken"
|
||||||
|
|
||||||
|
test "all lowercase":
|
||||||
|
check "thisisatest".toCamelCase() == "thisisatest"
|
||||||
|
|
||||||
|
test "all uppercase":
|
||||||
|
check "THISISATEST".toCamelCase() == "thisisatest"
|
||||||
Reference in New Issue
Block a user