Skip to content

Commit

Permalink
Rewrote main tests file
Browse files Browse the repository at this point in the history
Gives a nice example of how to use the `ItemAccessWrapper` builder and where `BaseItemContainer` comes from
  • Loading branch information
nbness2 committed May 4, 2019
1 parent 240897d commit 2c6dc35
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
38 changes: 38 additions & 0 deletions src/test/kotlin/Tests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import itemstuff.BaseItem
import container.Container
import item.itemAccessWrapper

val baseItemAccess = itemAccessWrapper<BaseItem> {
getItemId(BaseItem::itemId)
getItemAmount(BaseItem::itemAmount)
getIsStackable(BaseItem::isStackable)
createItem(::BaseItem)
}

fun BaseItemContainer(alwaysStackable: Boolean = false, vararg items: BaseItem): Container<BaseItem> =
Container(items.size, alwaysStackable, baseItemAccess, items::get)

/**
* @author: nbness2 <nbness1337@gmail.com>
*
* Tests for [Container]s Safe Access
*/
fun main() {
// No tests for getFromSlot and set specifically because they will propagate through some of these tests and make them wrong.
shiftTest()
addItemTest()
hasRoomTest()
verifyTest()
swapSlotTest()
takeItemTest()
}


/**
* @author: nbness2 <nbness1337@gmail.com>
*
*
*/
fun expectedGot(testName: String, expected: Any, got: Any): String =
"Test($testName): Expected $expected -- got $got"

27 changes: 0 additions & 27 deletions test/Tests.kt

This file was deleted.

0 comments on commit 2c6dc35

Please sign in to comment.