link more documentation to test cases and filled out the test cases a little

This commit is contained in:
James Strachan
2012-03-27 12:26:20 +01:00
parent 31fd665913
commit 133afa8327
9 changed files with 106 additions and 58 deletions
+12 -16
View File
@@ -2,18 +2,14 @@ package test.collections
import kotlin.test.*
// TODO can we avoid importing all this stuff by default I wonder?
// e.g. making println and the collection builder methods public by default?
import kotlin.*
import kotlin.io.*
import kotlin.util.*
import java.util.*
import junit.framework.TestCase
import org.junit.Test
class MapTest() : TestCase() {
val data: java.util.Map<String, Int> = java.util.HashMap<String, Int>()
class MapTest {
fun testGetOrElse() {
Test fun getOrElse() {
val data = HashMap<String, Int>()
val a = data.getOrElse("foo"){2}
assertEquals(2, a)
@@ -22,7 +18,8 @@ class MapTest() : TestCase() {
assertEquals(0, data.size())
}
fun testGetOrPut() {
Test fun getOrPut() {
val data = HashMap<String, Int>()
val a = data.getOrPut("foo"){2}
assertEquals(2, a)
@@ -32,17 +29,16 @@ class MapTest() : TestCase() {
assertEquals(1, data.size())
}
fun testSizeAndEmpty() {
Test fun sizeAndEmpty() {
val data = HashMap<String, Int>()
assertTrue{ data.empty }
// TODO using size breaks a test case
assertEquals(data.size(), 0)
assertEquals(data.size, 0)
}
fun testSetViaIndexOperators() {
val map = java.util.HashMap<String, String>()
Test fun setViaIndexOperators() {
val map = HashMap<String, String>()
assertTrue{ map.empty }
// TODO using size breaks a test case
assertEquals(map.size(), 0)
assertEquals(map.size, 0)
map["name"] = "James"