Advertisement
pellekrogholt

Untitled

Dec 18th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1.  
  2. test("Test empty tree 'Contains'") {
  3.  
  4. // behind the scene this on create a node actor - follow props: Props(classOf[BinaryTreeNode], elem, initiallyRemoved)
  5. val testNode = system.actorOf(BinaryTreeNode.props(0, true))
  6.  
  7. testNode ! Contains(testActor, id = 1, 0)
  8. expectMsg(ContainsResult(1, false))
  9. }
  10.  
  11. test("Test empty tree 'Insert'") {
  12. val testNode = system.actorOf(BinaryTreeNode.props(0, true))
  13.  
  14. testNode ! Insert(testActor, id = 1, 42)
  15. expectMsg(OperationFinished(1))
  16. testNode ! Contains(testActor, id = 2, 42)
  17. expectMsg(ContainsResult(2, true))
  18. }
  19.  
  20.  
  21. test("simple inserts and lookups") {
  22. val topNode = system.actorOf(Props[BinaryTreeSet])
  23.  
  24. topNode ! Contains(testActor, id = 1, 1)
  25. expectMsg(ContainsResult(1, false))
  26.  
  27. topNode ! Insert(testActor, id = 2, 1)
  28. topNode ! Contains(testActor, id = 3, 1)
  29.  
  30. expectMsg(OperationFinished(2))
  31. expectMsg(ContainsResult(3, true))
  32. }
  33.  
  34. test("proper inserts and lookups") {
  35. val topNode = system.actorOf(Props[BinaryTreeSet])
  36.  
  37. topNode ! Contains(testActor, id = 1, 1)
  38. expectMsg(ContainsResult(1, false))
  39.  
  40. topNode ! Insert(testActor, id = 2, 1)
  41. topNode ! Contains(testActor, id = 3, 1)
  42.  
  43. expectMsg(OperationFinished(2))
  44. expectMsg(ContainsResult(3, true))
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement