-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
21 changed files
with
140 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ktx.app | ||
|
||
import com.badlogic.gdx.utils.GdxRuntimeException | ||
|
||
/** | ||
* Throws a [GdxRuntimeException]. The [message] will be converted to string and passed as the exception message. | ||
* The [cause] is an optional exception cause. See also: [error]. | ||
*/ | ||
@Suppress("NOTHING_TO_INLINE") | ||
inline fun gdxError(message: Any? = null, cause: Throwable? = null): Nothing = | ||
throw GdxRuntimeException(message.toString(), cause) |
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,55 @@ | ||
package ktx.app | ||
|
||
import com.badlogic.gdx.utils.GdxRuntimeException | ||
import io.kotlintest.matchers.shouldThrow | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertSame | ||
import org.junit.Test | ||
|
||
class ExceptionsTest { | ||
@Test | ||
fun `should throw error`() { | ||
shouldThrow<GdxRuntimeException> { | ||
gdxError() | ||
} | ||
} | ||
|
||
@Test | ||
fun `should throw error given a null message`() { | ||
val exception = shouldThrow<GdxRuntimeException> { | ||
gdxError(null) | ||
} | ||
|
||
assertEquals("null", exception.message) | ||
} | ||
|
||
@Test | ||
fun `should throw error given a string message`() { | ||
val exception = shouldThrow<GdxRuntimeException> { | ||
gdxError("Test") | ||
} | ||
|
||
assertEquals("Test", exception.message) | ||
} | ||
|
||
@Test | ||
fun `should throw error given an object message`() { | ||
val exception = shouldThrow<GdxRuntimeException> { | ||
gdxError(42) | ||
} | ||
|
||
assertEquals("42", exception.message) | ||
} | ||
|
||
@Test | ||
fun `should throw error given a cause`() { | ||
val cause = Exception() | ||
|
||
val exception = shouldThrow<GdxRuntimeException> { | ||
gdxError("Message", cause) | ||
} | ||
|
||
assertEquals("Message", exception.message) | ||
assertSame(cause, exception.cause) | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import ktx.* | ||
|
||
dependencies { | ||
compileOnly("com.badlogicgames.gdx:gdx-box2d:$gdxVersion") | ||
api("com.badlogicgames.gdx:gdx-box2d:$gdxVersion") | ||
testImplementation("com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop") | ||
} |
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
Oops, something went wrong.