Skip to content

Commit

Permalink
test updated to work with JS
Browse files Browse the repository at this point in the history
  • Loading branch information
morisil committed Sep 6, 2024
1 parent 7bc5a35 commit 6fa22b1
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions xemantic-osc-api/src/commonTest/kotlin/type/OscTypeTagsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
package com.xemantic.osc.type

import com.xemantic.osc.OscException
import io.kotest.assertions.throwables.shouldThrow
import kotlin.test.Test
import io.kotest.matchers.shouldBe
import io.kotest.assertions.throwables.shouldThrowWithMessage
import io.kotest.matchers.string.shouldStartWith

class OscTypeTagTest {

Expand All @@ -30,11 +32,6 @@ class OscTypeTagTest {
42.oscTypeTag shouldBe "i"
}

@Test
fun floatOscTypeTagShouldBeF() {
3.14f.oscTypeTag shouldBe "f"
}

@Test
fun stringOscTypeTagShouldBeS() {
"Hello".oscTypeTag shouldBe "s"
Expand Down Expand Up @@ -65,11 +62,6 @@ class OscTypeTagTest {
OscTimeTag.now().oscTypeTag shouldBe "t"
}

@Test
fun longOscTypeTagShouldBeH() {
123456789L.oscTypeTag shouldBe "h"
}

@Test
fun doubleOscTypeTagShouldBeD() {
2.71828.oscTypeTag shouldBe "d"
Expand All @@ -92,25 +84,21 @@ class OscTypeTagTest {

@Test
fun nestedListTypeTagsShouldBeCorrect() {
listOf(42, "Hello", true, null, listOf(3.14f, listOf('A'))).oscTypeTags() shouldBe "isTN[f[c]]"
listOf(42, "Hello", true, null, listOf(3.14, listOf('A'))).oscTypeTags() shouldBe "isTN[d[c]]"
}

@Test
fun unsupportedOscTypeShouldThrowException() {
shouldThrowWithMessage<OscException>(
"Type unsupported in OSC: class kotlin.Byte"
) {
0.toByte().oscTypeTag
}
shouldThrow<OscException> {
mapOf<String, String>().oscTypeTag
}.message shouldStartWith "Type unsupported in OSC"
}

@Test
fun listWithUnsupportedOscTypeShouldThrowException() {
shouldThrowWithMessage<OscException>(
"Type unsupported in OSC: class kotlin.Any"
) {
listOf(42, Any()).oscTypeTags()
}
fun listContainingUnsupportedOscTypeShouldThrowException() {
shouldThrow<OscException> {
listOf(42, mapOf<String, String>()).oscTypeTags()
}.message shouldStartWith "Type unsupported in OSC"
}

@Test
Expand Down

0 comments on commit 6fa22b1

Please sign in to comment.