-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kenneth J. Shackleton <[email protected]>
- Loading branch information
1 parent
e6bdd0f
commit 39d8d7d
Showing
7 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
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
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,21 @@ | ||
/* | ||
* Copyright 2021 Bloomberg Finance L.P. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.bloomberg.selekt.commons | ||
|
||
internal fun Char.isEnglishLetter() = this in 'A'..'Z' || this in 'a'..'z' | ||
|
||
internal fun Char.isNotEnglishLetter() = !isEnglishLetter() |
31 changes: 31 additions & 0 deletions
31
Lib/src/main/kotlin/com/bloomberg/selekt/commons/Strings.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,31 @@ | ||
/* | ||
* Copyright 2021 Bloomberg Finance L.P. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.bloomberg.selekt.commons | ||
|
||
import com.bloomberg.selekt.annotations.Generated | ||
|
||
@Generated | ||
internal inline fun String.trimStartByIndex(predicate: (Char) -> Boolean): String { | ||
var i = 0 | ||
while (i < length) { | ||
if (!predicate(this[i])) { | ||
return substring(i) | ||
} | ||
++i | ||
} | ||
return "" | ||
} |
42 changes: 42 additions & 0 deletions
42
Lib/src/test/kotlin/com/bloomberg/selekt/commons/CharsTest.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,42 @@ | ||
/* | ||
* Copyright 2021 Bloomberg Finance L.P. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.bloomberg.selekt.commons | ||
|
||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertTrue | ||
|
||
internal class CharsTest { | ||
@Test | ||
fun isEnglishLetterLowercase() { | ||
assertTrue('a'.isEnglishLetter()) | ||
} | ||
|
||
@Test | ||
fun isEnglishLetterUppercase() { | ||
assertTrue('A'.isEnglishLetter()) | ||
} | ||
|
||
@Test | ||
fun isNotEnglishLetterDigit() { | ||
assertTrue('1'.isNotEnglishLetter()) | ||
} | ||
|
||
@Test | ||
fun isNotEnglishLetterSymbol() { | ||
assertTrue('{'.isNotEnglishLetter()) | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
Lib/src/test/kotlin/com/bloomberg/selekt/commons/StringsTest.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,56 @@ | ||
/* | ||
* Copyright 2021 Bloomberg Finance L.P. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.bloomberg.selekt.commons | ||
|
||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertSame | ||
|
||
internal class StringsTest { | ||
@Test | ||
fun trimStartByIndexEmptyBlankSpace() { | ||
"".let { | ||
assertSame(it, it.trimStartByIndex(Char::isWhitespace)) | ||
} | ||
} | ||
|
||
@Test | ||
fun trimStartByIndexNoBlankSpace() { | ||
"SELECT * FROM Foo".let { | ||
assertSame(it, it.trimStartByIndex(Char::isWhitespace)) | ||
} | ||
} | ||
|
||
@Test | ||
fun trimStartByIndexWithBlankSpace() { | ||
val sql = " SELECT * FROM Foo" | ||
assertEquals("SELECT * FROM Foo", sql.trimStartByIndex(Char::isWhitespace)) | ||
} | ||
|
||
@Test | ||
fun trimStartByIndexWithBlankSpaceOnlyAfter() { | ||
"SELECT * FROM Foo ".let { | ||
assertEquals(it, it.trimStartByIndex(Char::isWhitespace)) | ||
} | ||
} | ||
|
||
@Test | ||
fun trimStartByIndexWithBlankSpaceBeforeAndAfter() { | ||
val sql = " SELECT * FROM Foo " | ||
assertEquals("SELECT * FROM Foo ", sql.trimStartByIndex(Char::isWhitespace)) | ||
} | ||
} |
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,4 +1,4 @@ | ||
selekt.versionName=0.13.1 | ||
selekt.versionName=0.13.2 | ||
|
||
openssl.version=1.1.1 | ||
openssl.version.suffix=d | ||
|