Last active
December 16, 2015 10:39
-
-
Save ib84/5421735 to your computer and use it in GitHub Desktop.
Naive version of a series of tests (validations) for a test.
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
val validatations : Seq[(String, (S,Seq[(K,Seq[V])]) => Try[Boolean])]= | |
Seq( | |
("def findLT(key: K)", (index:S, dataSeq:Seq[(K,Seq[V])]) => Try | |
{ | |
val allTrue = dataSeq.forall{ case (key, valueSeq) => | |
{ | |
val b = index.findLT(key) | |
val ordering = implicitly[Ordering[K]] | |
val c = dataSeq.filter( pair => ordering.lt(pair._1, key)).map(_._1).toSet | |
b.forall(key => c.contains(key)) | |
} | |
} | |
assert(allTrue, "findLT failed") | |
allTrue | |
} | |
), | |
("def findGT(key: K)", (index:S, dataSeq:Seq[(K,Seq[V])]) => Try | |
{ | |
val allTrue = dataSeq.forall{ case (key, valueSeq) => | |
{ | |
val b = index.findGT(key) | |
val ordering = implicitly[Ordering[K]] | |
val c = dataSeq.filter( pair => ordering.gt(pair._1, key)).map(_._1).toSet | |
b.forall(key => c.contains(key)) | |
} | |
} | |
assert(allTrue, "findGT failed") | |
allTrue | |
} | |
), | |
("def findLTE(key: K)", (index:S, dataSeq:Seq[(K,Seq[V])]) => Try | |
{ | |
val allTrue = dataSeq.forall{ case (key, valueSeq) => | |
{ | |
val b = index.findLTE(key) | |
val ordering = implicitly[Ordering[K]] | |
val c = dataSeq.filter( pair => ordering.lteq(pair._1, key)).map(_._1).toSet | |
b.forall(key => c.contains(key)) | |
} | |
} | |
assert(allTrue, "findLTE failed") | |
allTrue | |
} | |
), | |
("def findGTE(key: K)", (index:S, dataSeq:Seq[(K,Seq[V])]) => Try | |
{ | |
val allTrue = dataSeq.forall{ case (key, valueSeq) => | |
{ | |
val b = index.findGTE(key) | |
val ordering = implicitly[Ordering[K]] | |
val c = dataSeq.filter( pair => ordering.gteq(pair._1, key)).map(_._1).toSet | |
b.forall(key => c.contains(key)) | |
} | |
} | |
assert(allTrue, "findGTE failed") | |
allTrue | |
} | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment