-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
8 changed files
with
100 additions
and
13 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
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
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
41 changes: 41 additions & 0 deletions
41
app/src/test/kotlin/at/bitfire/davdroid/log/StringHandlerTest.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,41 @@ | ||
/* | ||
* Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details. | ||
*/ | ||
|
||
package at.bitfire.davdroid.log | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import java.util.logging.Formatter | ||
import java.util.logging.Level | ||
import java.util.logging.LogRecord | ||
|
||
class StringHandlerTest { | ||
|
||
@Test | ||
fun test_logSomeText() { | ||
val handler = StringHandler(1000) | ||
handler.publish(LogRecord(Level.INFO, "Line 1")) | ||
handler.publish(LogRecord(Level.FINEST, "Line 2")) | ||
val str = handler.toString() | ||
assertTrue(str.contains("Line 1\n")) | ||
assertTrue(str.contains("Line 2\n")) | ||
} | ||
|
||
@Test | ||
fun test_logSomeText_ExceedingMaxSize() { | ||
val handler = StringHandler(10).apply { | ||
formatter = object: Formatter() { | ||
override fun format(record: LogRecord) = record.message | ||
} | ||
} | ||
handler.publish(LogRecord(Level.INFO, "Line 1 Line 1 Line 1 Line 1 Line 1")) | ||
handler.publish(LogRecord(Level.FINEST, "Line 2")) | ||
|
||
val str = handler.toString() | ||
assertEquals(10, handler.toString().length) | ||
assertEquals("Line [...]", str) | ||
} | ||
|
||
} |