forked from pinterest/ktlint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for customizing the output color for pinterest#582.
- Loading branch information
Showing
6 changed files
with
144 additions
and
16 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
68 changes: 68 additions & 0 deletions
68
...er-plain/src/test/kotlin/com/pinterest/ktlint/reporter/plain/PlainReporterProviderTest.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,68 @@ | ||
package com.pinterest.ktlint.reporter.plain | ||
|
||
import com.pinterest.ktlint.reporter.plain.internal.Color | ||
import java.io.PrintStream | ||
import java.lang.System.out | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.fail | ||
import org.junit.Test | ||
|
||
class PlainReporterProviderTest { | ||
@Test | ||
fun testNoColorNameProvided() { | ||
try { | ||
PlainReporterProvider().get( | ||
out = PrintStream(out, true), | ||
opt = mapOf() | ||
) as PlainReporter | ||
|
||
fail("Expected IllegalArgumentException.") | ||
} catch (iae: IllegalArgumentException) { | ||
// Expected case | ||
} catch (e: Exception) { | ||
fail("Expected IllegalArgumentException but was: $e") | ||
} | ||
} | ||
|
||
@Test | ||
fun testEmptyColorNameProvided() { | ||
try { | ||
PlainReporterProvider().get( | ||
out = PrintStream(out, true), | ||
opt = mapOf("color_name" to "") | ||
) as PlainReporter | ||
|
||
fail("Expected IllegalArgumentException.") | ||
} catch (iae: IllegalArgumentException) { | ||
// Expected case | ||
} catch (e: Exception) { | ||
fail("Expected IllegalArgumentException but was: $e") | ||
} | ||
} | ||
|
||
@Test | ||
fun testValidColorNameProvided() { | ||
val plainReporter = PlainReporterProvider().get( | ||
out = PrintStream(out, true), | ||
opt = mapOf("color_name" to "RED") | ||
) as PlainReporter | ||
|
||
assertEquals(Color.RED, plainReporter.color) | ||
} | ||
|
||
@Test | ||
fun testInvalidColorNameProvided() { | ||
try { | ||
PlainReporterProvider().get( | ||
out = PrintStream(out, true), | ||
opt = mapOf("colo_namer" to "GARBAGE_INPUT") | ||
) as PlainReporter | ||
|
||
fail("Expected IllegalArgumentException.") | ||
} catch (iae: IllegalArgumentException) { | ||
// Expected case | ||
} catch (e: Exception) { | ||
fail("Expected IllegalArgumentException but was: $e") | ||
} | ||
} | ||
} |
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