Skip to content

Instantly share code, notes, and snippets.

@jordanlewis
Created December 4, 2012 23:46
Show Gist options
  • Save jordanlewis/4210365 to your computer and use it in GitHub Desktop.
Save jordanlewis/4210365 to your computer and use it in GitHub Desktop.
PFDS Exercise 2.5 tests
class BinaryTreeTest extends Spec with ShouldMatchers with Checkers {
describe("A complete tree") {
it("should have 2^n - 1 nodes") {
check(forAll(choose(0, 25)){n: Int =>
BinaryTree.complete(0, n).size == scala.math.pow(2, n) - 1 })
}
}
describe("A balanced tree") {
it("should have n nodes") {
check(forAll(choose(0, 100)){n: Int =>
BinaryTree.balanced(0, n).size == n})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment