-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
158 additions
and
137 deletions.
There are no files selected for viewing
77 changes: 0 additions & 77 deletions
77
src/commonTest/kotlin/net/pearx/kasechange/test/CaseFormatTest.kt
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/commonTest/kotlin/net/pearx/kasechange/test/CaseFormatterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package net.pearx.kasechange.test | ||
|
||
import net.pearx.kasechange.CaseFormat | ||
import net.pearx.kasechange.formatter.CaseFormatterConfig | ||
import net.pearx.kasechange.formatter.CaseFormatterConfigurable | ||
import net.pearx.kasechange.formatter.format | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class CaseFormatterTest { | ||
|
||
@Test | ||
fun testCamel() { | ||
assertEquals("xmlHttpRequestV2Updated", CaseFormat.CAMEL.format("XmL", "http", "reQuEST", "v2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testPascal() { | ||
assertEquals("XmlHttpRequestV2Updated", CaseFormat.CAPITALIZED_CAMEL.format("xml", "HTTP", "reQuEsT", "v2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testSnake() { | ||
assertEquals("xml_http_request_v2_updated", CaseFormat.LOWER_UNDERSCORE.format("XML", "htTp", "REQUEST", "V2", "updated")) | ||
} | ||
|
||
@Test | ||
fun testScreamingSnake() { | ||
assertEquals("XML_HTTP_REQUEST_V2_UPDATED", CaseFormat.UPPER_UNDERSCORE.format("xml", "HTTP", "reQUEst", "v2", "updated")) | ||
} | ||
|
||
@Test | ||
fun testKebab() { | ||
assertEquals("xml-http-request-v2-updated", CaseFormat.LOWER_HYPHEN.format("XML", "http", "reQuEST", "V2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testTrain() { | ||
assertEquals("XML-HTTP-REQUEST-V2-UPDATED", CaseFormat.UPPER_HYPHEN.format("XML", "http", "reQuEST", "V2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testLowerSpace() { | ||
assertEquals("xml http request v2 updated", CaseFormat.LOWER_SPACE.format("XML", "http", "reQuEST", "V2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testUpperSpace() { | ||
assertEquals("XML HTTP REQUEST V2 UPDATED", CaseFormat.UPPER_SPACE.format("XmL", "http", "reQuEST", "v2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testTitle() { | ||
assertEquals("Xml Http Request V2 Updated", CaseFormat.CAPITALIZED_SPACE.format("XmL", "http", "reQuEST", "v2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testDot() { | ||
assertEquals("xml.http.request.v2.updated", CaseFormat.LOWER_DOT.format("XML", "http", "reQuEST", "V2", "Updated")) | ||
} | ||
|
||
@Test | ||
fun testDotUpper() { | ||
assertEquals("XML.HTTP.REQUEST.V2.UPDATED", CaseFormat.UPPER_DOT.format("xml", "HTTP", "reQUEst", "v2", "updated")) | ||
} | ||
|
||
@Test | ||
fun testConfig() { | ||
assertEquals("Xml**Http**Request**V2**Updated", CaseFormatterConfigurable(CaseFormatterConfig(false, "**", wordCapitalize = true, firstWordCapitalize = true)).format("XmL", "http", "REQUEST", "v2", "uPDated")) | ||
} | ||
} |
34 changes: 14 additions & 20 deletions
34
src/commonTest/kotlin/net/pearx/kasechange/test/ComplexTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,69 @@ | ||
/* | ||
* Copyright © 2019, PearX Team | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package net.pearx.kasechange.test | ||
|
||
import net.pearx.kasechange.* | ||
import net.pearx.kasechange.formatter.CaseFormatterConfig | ||
import net.pearx.kasechange.formatter.CaseFormatterConfigurable | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class ComplexTest { | ||
@Test | ||
fun testCamel() { | ||
assertEquals("someStringWith123Numbers", "Some String With 123 Numbers".toCamelCase()) | ||
assertEquals("xmlHttpRequestV2Updated", "xml_http_request_v2_updated".toCamelCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testPascal() { | ||
assertEquals("SomeStringWith123Numbers", "Some String With 123 Numbers".toPascalCase()) | ||
assertEquals("XmlHttpRequestV2Updated", "xml_http_request_v2_updated".toPascalCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testSnake() { | ||
assertEquals("some_string_with_123_numbers", "Some String With 123 Numbers".toSnakeCase()) | ||
assertEquals("xml_http_request_v2_updated", "XML_HTTP_REQUEST_V2_UPDATED".toSnakeCase(CaseFormat.UPPER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testScreamingSnake() { | ||
assertEquals("SOME_STRING_WITH_123_NUMBERS", "Some String With 123 Numbers".toScreamingSnakeCase()) | ||
assertEquals("XML_HTTP_REQUEST_V2_UPDATED", "xml_http_request_v2_updated".toScreamingSnakeCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testKebab() { | ||
assertEquals("some-string-with-123-numbers", "Some String With 123 Numbers".toKebabCase()) | ||
assertEquals("xml-http-request-v2-updated", "xml_http_request_v2_updated".toKebabCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testTrain() { | ||
assertEquals("SOME-STRING-WITH-123-NUMBERS", "Some String With 123 Numbers".toTrainCase()) | ||
assertEquals("XML-HTTP-REQUEST-V2-UPDATED", "xml_http_request_v2_updated".toTrainCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testLowerSpace() { | ||
assertEquals("some string with 123 numbers", "Some String With 123 Numbers".toLowerSpaceCase()) | ||
assertEquals("xml http request v2 updated", "xml_http_request_v2_updated".toLowerSpaceCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testUpperSpace() { | ||
assertEquals("SOME STRING WITH 123 NUMBERS", "Some String With 123 Numbers".toUpperSpaceCase()) | ||
assertEquals("XML HTTP REQUEST V2 UPDATED", "xml_http_request_v2_updated".toUpperSpaceCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testTitle() { | ||
assertEquals("Some String With 123 Numbers", "some string with 123 numbers".toTitleCase()) | ||
assertEquals("Xml Http Request V2 Updated", "xml_http_request_v2_updated".toTitleCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testDot() { | ||
assertEquals("some.string.with.123.numbers", "Some String With 123 Numbers".toDotCase()) | ||
assertEquals("xml.http.request.v2.updated", "xml_http_request_v2_updated".toDotCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testDotUpper() { | ||
assertEquals("SOME.STRING.WITH.123.NUMBERS", "Some String With 123 Numbers".toUpperDotCase()) | ||
assertEquals("XML.HTTP.REQUEST.V2.UPDATED", "xml_http_request_v2_updated".toUpperDotCase(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testConfig() { | ||
assertEquals("Some..String..With..123..Numbers", "Some String With 123 Numbers".toCase(CaseFormatterConfig(false, "..", wordCapitalize = true, firstWordCapitalize = true))) | ||
fun testMulti1() { | ||
assertEquals("My**Xml**Request**V2**Updated", "MY XML-REQUEST.V2_UPDATED".toCase(CaseFormatterConfig(false, "**", wordCapitalize = true, firstWordCapitalize = true), universalWordSplitter(false))) | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
src/commonTest/kotlin/net/pearx/kasechange/test/SplitToWordsTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/commonTest/kotlin/net/pearx/kasechange/test/WordSplitterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package net.pearx.kasechange.test | ||
|
||
import net.pearx.kasechange.CaseFormat | ||
import net.pearx.kasechange.splitToWords | ||
import net.pearx.kasechange.splitter.WordSplitter | ||
import net.pearx.kasechange.splitter.WordSplitterConfig | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class WordSplitterTest { | ||
@Test | ||
fun testCamel() { | ||
assertEquals(listOf("xml", "Http", "Request", "V2", "Updated"), "xmlHttpRequestV2Updated".splitToWords(CaseFormat.CAMEL)) | ||
} | ||
|
||
@Test | ||
fun testPascal() { | ||
assertEquals(listOf("XML", "Http", "Request", "V2", "Updated"), "XMLHttpRequestV2Updated".splitToWords(CaseFormat.CAPITALIZED_CAMEL)) | ||
} | ||
|
||
@Test | ||
fun testSnake() { | ||
assertEquals(listOf("xml", "http", "request", "v2", "updated"), "xml_http_request_v2_updated".splitToWords(CaseFormat.LOWER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testScreamingSnake() { | ||
assertEquals(listOf("XML", "HTTP", "REQUEST", "V2", "UPDATED"), "XML_HTTP_REQUEST_V2_UPDATED".splitToWords(CaseFormat.UPPER_UNDERSCORE)) | ||
} | ||
|
||
@Test | ||
fun testKebab() { | ||
assertEquals(listOf("xml", "http", "request", "v2", "updated"), "xml-http-request-v2-updated".splitToWords(CaseFormat.LOWER_HYPHEN)) | ||
} | ||
|
||
@Test | ||
fun testTrain() { | ||
assertEquals(listOf("XML", "HTTP", "REQUEST", "V2", "UPDATED"), "XML-HTTP-REQUEST-V2-UPDATED".splitToWords(CaseFormat.UPPER_HYPHEN)) | ||
} | ||
|
||
@Test | ||
fun testLowerSpace() { | ||
assertEquals(listOf("xml", "http", "request", "v2", "updated"), "xml http request v2 updated".splitToWords(CaseFormat.LOWER_SPACE)) | ||
} | ||
|
||
@Test | ||
fun testUpperSpace() { | ||
assertEquals(listOf("XML", "HTTP", "REQUEST", "V2", "UPDATED"), "XML HTTP REQUEST V2 UPDATED".splitToWords(CaseFormat.UPPER_SPACE)) | ||
} | ||
|
||
@Test | ||
fun testTitle() { | ||
assertEquals(listOf("XML", "Request", "V2", "Updated"), "XML Request V2 Updated".splitToWords(CaseFormat.CAPITALIZED_SPACE)) | ||
} | ||
|
||
@Test | ||
fun testDot() { | ||
assertEquals(listOf("xml", "request", "v2", "updated"), "xml.request.v2.updated".splitToWords(CaseFormat.LOWER_DOT)) | ||
} | ||
|
||
@Test | ||
fun testDotUpper() { | ||
assertEquals(listOf("XML", "REQUEST", "V2", "UPDATED"), "XML.REQUEST.V2.UPDATED".splitToWords(CaseFormat.UPPER_DOT)) | ||
} | ||
|
||
@Test | ||
fun testConfig() { | ||
assertEquals(listOf("xml", "Request", "V2", "Updated"), "xml*Request*V2*Updated".splitToWords(WordSplitterConfig(boundaries = setOf('*')))) | ||
} | ||
} |