Created
July 13, 2019 20:32
-
-
Save twalk4821/f621a856ab712ed403b0756f8bf8507e to your computer and use it in GitHub Desktop.
DSL Tests
This file contains hidden or 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
package tylerwalker.io.dsl | |
import android.support.test.InstrumentationRegistry | |
import android.support.test.runner.AndroidJUnit4 | |
import android.text.SpannableStringBuilder | |
import org.junit.Test | |
import org.junit.runner.RunWith | |
import org.junit.Assert.* | |
/** | |
* Instrumented test, which will execute on an Android device. | |
* | |
* See [testing documentation](http://d.android.com/tools/testing). | |
*/ | |
@RunWith(AndroidJUnit4::class) | |
class DSLInstrumentTest { | |
@Test | |
fun canAddAtoms() { | |
val first = Atom(SpannableStringBuilder("Hello")) | |
val middle = Atom(SpannableStringBuilder(" ")) | |
val last = Atom(SpannableStringBuilder("World!")) | |
val result = first + middle + last | |
assertTrue(result.content.toString() == "Hello World!") | |
} | |
@Test | |
fun canAppend() { | |
val first = "Hello" | |
val middle = " " | |
val last = "World!" | |
val result = spannable { | |
+first | |
+middle | |
+last | |
} | |
assertTrue(result.toString() == "Hello World!") | |
} | |
@Test | |
fun canDoNestedAppend() { | |
val first = "Hello" | |
val middle = " " | |
val last = "World!" | |
val result = spannable { | |
+first | |
append { | |
+middle | |
+last | |
} | |
} | |
assertTrue(result.toString() == "Hello World!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment