-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
1 parent
9b36c62
commit e6cb5a3
Showing
19 changed files
with
567 additions
and
625 deletions.
There are no files selected for viewing
43 changes: 0 additions & 43 deletions
43
core-util-jvm/src/test/java/org/signal/core/util/logging/LogTest.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
core-util-jvm/src/test/java/org/signal/core/util/logging/LogTest.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,36 @@ | ||
/* | ||
* Copyright 2023 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
package org.signal.core.util.logging | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class LogTest { | ||
@Test | ||
fun tag_short_class_name() { | ||
assertEquals("MyClass", Log.tag(MyClass::class)) | ||
} | ||
|
||
@Test | ||
fun tag_23_character_class_name() { | ||
val tag = Log.tag(TwentyThreeCharacters23::class) | ||
assertEquals("TwentyThreeCharacters23", tag) | ||
assertEquals(23, tag.length) | ||
} | ||
|
||
@Test | ||
fun tag_24_character_class_name() { | ||
assertEquals(24, TwentyFour24Characters24::class.simpleName!!.length) | ||
val tag = Log.tag(TwentyFour24Characters24::class) | ||
assertEquals("TwentyFour24Characters2", tag) | ||
assertEquals(23, Log.tag(TwentyThreeCharacters23::class).length) | ||
} | ||
|
||
private inner class MyClass | ||
|
||
private inner class TwentyThreeCharacters23 | ||
|
||
private inner class TwentyFour24Characters24 | ||
} |
104 changes: 0 additions & 104 deletions
104
core-util/src/test/java/org/signal/core/util/BreakIteratorCompatTest.java
This file was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
core-util/src/test/java/org/signal/core/util/BreakIteratorCompatTest.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,92 @@ | ||
package org.signal.core.util | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class BreakIteratorCompatTest { | ||
@Test | ||
fun empty() { | ||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText("") | ||
|
||
assertEquals(BreakIteratorCompat.DONE, breakIterator.next()) | ||
} | ||
|
||
@Test | ||
fun single() { | ||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText("a") | ||
|
||
assertEquals(1, breakIterator.next()) | ||
assertEquals(BreakIteratorCompat.DONE, breakIterator.next()) | ||
} | ||
|
||
@Test | ||
fun count_empty() { | ||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText("") | ||
|
||
assertEquals(0, breakIterator.countBreaks()) | ||
assertEquals(BreakIteratorCompat.DONE, breakIterator.next()) | ||
} | ||
|
||
@Test | ||
fun count_simple_text() { | ||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText("abc") | ||
|
||
assertEquals(3, breakIterator.countBreaks()) | ||
assertEquals(BreakIteratorCompat.DONE, breakIterator.next()) | ||
} | ||
|
||
@Test | ||
fun two_counts() { | ||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText("abc") | ||
|
||
assertEquals(3, breakIterator.countBreaks()) | ||
assertEquals(BreakIteratorCompat.DONE, breakIterator.next()) | ||
assertEquals(3, breakIterator.countBreaks()) | ||
} | ||
|
||
@Test | ||
fun count_multi_character_graphemes() { | ||
val hindi = "समाजो गयेग" | ||
|
||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText(hindi) | ||
|
||
assertEquals(7, breakIterator.countBreaks()) | ||
assertEquals(BreakIteratorCompat.DONE, breakIterator.next()) | ||
} | ||
|
||
@Test | ||
fun iterate_multi_character_graphemes() { | ||
val hindi = "समाजो गयेग" | ||
|
||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText(hindi) | ||
|
||
assertEquals(listOf("स", "मा", "जो", " ", "ग", "ये", "ग"), breakIterator.toList()) | ||
assertEquals(BreakIteratorCompat.DONE, breakIterator.next()) | ||
} | ||
|
||
@Test | ||
fun split_multi_character_graphemes() { | ||
val hindi = "समाजो गयेग" | ||
|
||
val breakIterator = BreakIteratorCompat.getInstance() | ||
breakIterator.setText(hindi) | ||
|
||
assertEquals("समाजो गयेग", breakIterator.take(8)) | ||
assertEquals("समाजो गयेग", breakIterator.take(7)) | ||
assertEquals("समाजो गये", breakIterator.take(6)) | ||
assertEquals("समाजो ग", breakIterator.take(5)) | ||
assertEquals("समाजो ", breakIterator.take(4)) | ||
assertEquals("समाजो", breakIterator.take(3)) | ||
assertEquals("समा", breakIterator.take(2)) | ||
assertEquals("स", breakIterator.take(1)) | ||
assertEquals("", breakIterator.take(0)) | ||
assertEquals("", breakIterator.take(-1)) | ||
} | ||
} |
52 changes: 0 additions & 52 deletions
52
core-util/src/test/java/org/signal/core/util/ListUtilTest.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
core-util/src/test/java/org/signal/core/util/ListUtilTest.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,47 @@ | ||
package org.signal.core.util | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class ListUtilTest { | ||
@Test | ||
fun chunk_oneChunk() { | ||
val input = listOf("A", "B", "C") | ||
|
||
var output = ListUtil.chunk(input, 3) | ||
assertEquals(1, output.size) | ||
assertEquals(input, output[0]) | ||
|
||
output = ListUtil.chunk(input, 4) | ||
assertEquals(1, output.size) | ||
assertEquals(input, output[0]) | ||
|
||
output = ListUtil.chunk(input, 100) | ||
assertEquals(1, output.size) | ||
assertEquals(input, output[0]) | ||
} | ||
|
||
@Test | ||
fun chunk_multipleChunks() { | ||
val input: List<String> = listOf("A", "B", "C", "D", "E") | ||
|
||
var output = ListUtil.chunk(input, 4) | ||
assertEquals(2, output.size) | ||
assertEquals(listOf("A", "B", "C", "D"), output[0]) | ||
assertEquals(listOf("E"), output[1]) | ||
|
||
output = ListUtil.chunk(input, 2) | ||
assertEquals(3, output.size) | ||
assertEquals(listOf("A", "B"), output[0]) | ||
assertEquals(listOf("C", "D"), output[1]) | ||
assertEquals(listOf("E"), output[2]) | ||
|
||
output = ListUtil.chunk(input, 1) | ||
assertEquals(5, output.size) | ||
assertEquals(listOf("A"), output[0]) | ||
assertEquals(listOf("B"), output[1]) | ||
assertEquals(listOf("C"), output[2]) | ||
assertEquals(listOf("D"), output[3]) | ||
assertEquals(listOf("E"), output[4]) | ||
} | ||
} |
Oops, something went wrong.