Skip to content

Commit

Permalink
Rewrite tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrapplexz committed Dec 28, 2019
1 parent 1637316 commit 5baad15
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 137 deletions.
77 changes: 0 additions & 77 deletions src/commonTest/kotlin/net/pearx/kasechange/test/CaseFormatTest.kt

This file was deleted.

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 src/commonTest/kotlin/net/pearx/kasechange/test/ComplexTest.kt
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)))
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ class UniversalWordSplitter2Test {

@Test
fun testTitle() {
assertEquals(listOf("XML", "Request", "V2", "Updated"), "XML Request V2 Updated".splitToWords(universalWordSplitter(false)))
assertEquals(listOf("XML", "Http", "Request", "V2", "Updated"), "XML Http Request V2 Updated".splitToWords(universalWordSplitter(false)))
}

@Test
fun testDot() {
assertEquals(listOf("xml", "request", "v2", "updated"), "xml.request.v2.updated".splitToWords(universalWordSplitter(false)))
assertEquals(listOf("xml", "http", "request", "v2", "updated"), "xml.http.request.v2.updated".splitToWords(universalWordSplitter(false)))
}

@Test
fun testDotUpper() {
assertEquals(listOf("XML", "REQUEST", "V2", "UPDATED"), "XML.REQUEST.V2.UPDATED".splitToWords(universalWordSplitter(false)))
assertEquals(listOf("XML", "HTTP", "REQUEST", "V2", "UPDATED"), "XML.HTTP.REQUEST.V2.UPDATED".splitToWords(universalWordSplitter(false)))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

package net.pearx.kasechange.test

import net.pearx.kasechange.formatter.CaseFormatterConfig
import net.pearx.kasechange.toCase
import net.pearx.kasechange.splitToWords
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down
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('*'))))
}
}

0 comments on commit 5baad15

Please sign in to comment.