Skip to content

Commit

Permalink
Improve failed assertSame/NotSame messages, correct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-g committed Oct 13, 2017
1 parent e611b9a commit 485ca10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ interface Asserter {
* @param message the message to report if the assertion fails.
*/
fun assertSame(message: String?, expected: Any?, actual: Any?): Unit {
assertTrue({ messagePrefix(message) + "Expected <$expected>, actual <$actual>." }, actual === expected)
assertTrue({ messagePrefix(message) + "Expected <$expected>, actual <$actual> is not same." }, actual === expected)
}

/**
Expand All @@ -200,7 +200,7 @@ interface Asserter {
* @param message the message to report if the assertion fails.
*/
fun assertNotSame(message: String?, illegal: Any?, actual: Any?): Unit {
assertTrue({ messagePrefix(message) + "Illegal value: <$actual>." }, actual !== illegal)
assertTrue({ messagePrefix(message) + "Expected not same as <$actual>." }, actual !== illegal)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class BasicAssertionsTest {
fun testAssertSameFails() {
val instance1: Any = object {}
val instance2: Any = object {}
checkFailedAssertion { assertEquals(instance1, instance2) }
checkFailedAssertion { assertSame(instance1, instance2) }
}

@Test
Expand Down Expand Up @@ -124,7 +124,7 @@ class BasicAssertionsTest {
fun testAssertNotSame() {
val instance1: Any = object {}
val instance2: Any = object {}
assertNotEquals(instance1, instance2)
assertNotSame(instance1, instance2)
}

@Test()
Expand All @@ -135,7 +135,7 @@ class BasicAssertionsTest {
@Test
fun testAssertNotSameFails() {
val instance: Any = object {}
checkFailedAssertion { assertNotEquals(instance, instance) }
checkFailedAssertion { assertNotSame(instance, instance) }
}

@Test
Expand Down

0 comments on commit 485ca10

Please sign in to comment.