-
Notifications
You must be signed in to change notification settings - Fork 11
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
3 changed files
with
71 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package dislike; | ||
|
||
import com.materialkolor.dislike.DislikeAnalyzer | ||
import com.materialkolor.hct.Hct | ||
import io.kotest.matchers.equals.shouldBeEqual | ||
import org.junit.jupiter.api.Test; | ||
import utils.shouldBeEqualColor | ||
|
||
class DislikeAnalyzerTest { | ||
|
||
@Test | ||
fun isDislikedFalse() { | ||
val expectedHct = hct.Hct.fromInt(0xB44C43) | ||
val expected = dislike.DislikeAnalyzer.isDisliked(expectedHct) | ||
|
||
val actualHct = Hct.fromInt(0xB44C43) | ||
val actual = DislikeAnalyzer.isDisliked(actualHct) | ||
|
||
expected shouldBeEqual actual | ||
expected shouldBeEqual false | ||
} | ||
|
||
@Test | ||
fun isDislikedTrue() { | ||
val expectedHct = hct.Hct.fromInt(0x9D9101) | ||
val expected = dislike.DislikeAnalyzer.isDisliked(expectedHct) | ||
|
||
val actualHct = Hct.fromInt(0x9D9101) | ||
val actual = DislikeAnalyzer.isDisliked(actualHct) | ||
|
||
expected shouldBeEqual actual | ||
expected shouldBeEqual true | ||
} | ||
|
||
@Test | ||
fun fixIfDisliked() { | ||
val expectedHct = hct.Hct.fromInt(0xB44C43) | ||
val expected = dislike.DislikeAnalyzer.fixIfDisliked(expectedHct) | ||
|
||
val actualHct = Hct.fromInt(0xB44C43) | ||
val actual = DislikeAnalyzer.fixIfDisliked(actualHct) | ||
|
||
expected shouldBeEqualColor actual | ||
} | ||
|
||
@Test | ||
fun fixIfDislikedFixed() { | ||
val expectedHct = hct.Hct.fromInt(0x9D9101) | ||
val expected = dislike.DislikeAnalyzer.fixIfDisliked(expectedHct) | ||
|
||
val actualHct = Hct.fromInt(0x9D9101) | ||
val actual = DislikeAnalyzer.fixIfDisliked(actualHct) | ||
|
||
expected shouldBeEqualColor actual | ||
} | ||
} |
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,12 @@ | ||
package utils | ||
|
||
import com.materialkolor.hct.Hct | ||
import io.kotest.matchers.equals.shouldBeEqual | ||
|
||
infix fun Hct.shouldBeEqualColor(expected: hct.Hct) { | ||
toInt() shouldBeEqual expected.toInt() | ||
} | ||
|
||
infix fun hct.Hct.shouldBeEqualColor(expected: Hct) { | ||
toInt() shouldBeEqual expected.toInt() | ||
} |