-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added min(), max(), average() and median() to MoneyList
- Loading branch information
1 parent
63ec831
commit 231212a
Showing
5 changed files
with
68 additions
and
5 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
43 changes: 43 additions & 0 deletions
43
money/src/test/java/de/tobiasschuerg/money/MoneyListTest.kt
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,43 @@ | ||
package de.tobiasschuerg.money | ||
|
||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
/** | ||
* Created by Tobias Schürg on 05.11.2017. | ||
*/ | ||
class MoneyListTest { | ||
|
||
private val currency = Currency("TST", "TEST", 1.0) | ||
private val list = MoneyList(currency) | ||
|
||
init { | ||
list.add(Money(3, currency)) | ||
list.add(Money(2, currency)) | ||
list.add(Money(6, currency)) | ||
list.add(Money(1, currency)) // min | ||
list.add(Money(4, currency)) | ||
list.add(Money(9, currency)) // max | ||
list.add(Money(7, currency)) | ||
list.add(Money(5, currency)) | ||
list.add(Money(8, currency)) | ||
} | ||
|
||
@Test | ||
fun minMax() { | ||
Assert.assertEquals(Money(1, currency), list.min()) | ||
Assert.assertEquals(Money(9, currency), list.max()) | ||
Assert.assertEquals(Money(5, currency), list.average()) | ||
Assert.assertEquals(Money(5, currency), list.median()) | ||
} | ||
|
||
@Test | ||
fun minMaxEmptyList() { | ||
val emptyList = MoneyList(currency) | ||
Assert.assertNull(emptyList.min()) | ||
Assert.assertNull(emptyList.max()) | ||
Assert.assertNull(emptyList.average()) | ||
Assert.assertNull(emptyList.median()) | ||
} | ||
|
||
} |