File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -104,15 +104,3 @@ inline fun <T> java.util.Collection<T>.notEmpty() : Boolean = !this.isEmpty()
104
104
inline fun <T > java.util.Collection<T>?.orEmpty () : Collection <T >
105
105
= if (this != null ) this else Collections .EMPTY_LIST as Collection <T >
106
106
107
- /* * Converts the string into a regular expression [[Pattern]] so that strings can be split or matched on */
108
- inline fun String.toRegex (): Pattern {
109
- return Pattern .compile(this ).sure()
110
- }
111
-
112
- /* *
113
- * Converts the string into a regular expression [[Pattern]] with the given flags from [[Pattern]] or'd together
114
- * so that strings can be split or matched on
115
- */
116
- inline fun String.toRegex (flags : Int ): Pattern {
117
- return Pattern .compile(this , flags).sure()
118
- }
Original file line number Diff line number Diff line change @@ -113,6 +113,15 @@ inline fun String.toLong() = java.lang.Long.parseLong(this).sure()
113
113
inline fun String.toFloat () = java.lang.Float .parseFloat(this ).sure()
114
114
inline fun String.toDouble () = java.lang.Double .parseDouble(this ).sure()
115
115
116
+ /* *
117
+ * Converts the string into a regular expression [[Pattern]] optionally
118
+ * with the specified flags from [[Pattern]] or'd together
119
+ * so that strings can be split or matched on.
120
+ */
121
+ inline fun String.toRegex (flags : Int =0): java.util.regex.Pattern {
122
+ return java.util.regex.Pattern .compile(this , flags).sure()
123
+ }
124
+
116
125
/* *
117
126
Iterator for characters of given CharSequence
118
127
*/
Original file line number Diff line number Diff line change @@ -33,4 +33,17 @@ class StringTest() : TestCase() {
33
33
assertEquals(" hey" , s.orEmpty())
34
34
assertEquals(" " , ns.orEmpty())
35
35
}
36
+
37
+ fun testToShort () {
38
+ assertEquals(77 .toShort(), " 77" .toShort())
39
+ }
40
+
41
+ fun testToInt () {
42
+ assertEquals(77 , " 77" .toInt())
43
+ }
44
+
45
+ fun testToLong () {
46
+ assertEquals(77 .toLong(), " 77" .toLong())
47
+ }
48
+
36
49
}
You can’t perform that action at this time.
0 commit comments