Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend IterableOnce in FactTable and add unit tests
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.rallyhealth.vapors.v1 | ||
|
||
package data | ||
|
||
import munit.FunSuite | ||
|
||
import java.time.LocalDate | ||
|
||
class FactTableSpec extends FunSuite { | ||
|
||
import example.FactTypes._ | ||
|
||
test("FactTable.iterator removes duplicates") { | ||
val allFacts = Seq[Fact](Age(23), Age(23), DateOfBirth(LocalDate.now())) | ||
val factTable = FactTable(allFacts) | ||
assertEquals(factTable.iterator.toSeq.sorted, allFacts.distinct.sorted) | ||
} | ||
|
||
test("FactTable.toSet") { | ||
val allFacts = Seq[Fact](Age(23), DateOfBirth(LocalDate.now()), Age(24)) | ||
val factTable = FactTable(allFacts) | ||
assertEquals(factTable.iterator.toSet, allFacts.toSet) | ||
} | ||
|
||
test("FactTable.toSeq") { | ||
val allFacts = Seq[Fact](Age(23), DateOfBirth(LocalDate.now()), Age(24)) | ||
val factTable = FactTable(allFacts) | ||
assertEquals(factTable.iterator.toSeq.sorted, allFacts.sorted) | ||
} | ||
} |