From c10dc78c957c62e86c2668fb0e1c811aae7a7c42 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 14 Dec 2018 21:58:02 +0800 Subject: [PATCH] add more test cases --- .../ch06_linkedlist/SinglyLinkedListTest.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scala/src/test/scala/ch06_linkedlist/SinglyLinkedListTest.scala b/scala/src/test/scala/ch06_linkedlist/SinglyLinkedListTest.scala index 91380fe..da5c3ed 100644 --- a/scala/src/test/scala/ch06_linkedlist/SinglyLinkedListTest.scala +++ b/scala/src/test/scala/ch06_linkedlist/SinglyLinkedListTest.scala @@ -149,6 +149,22 @@ class SinglyLinkedListTest extends FlatSpec with Matchers { assert(list.isPalindrome()) } + it should "not be isPalindrome for 012332100" in { + val list: SinglyLinkedList = new SinglyLinkedList() + for (i <- 0 to 3) { + list.insertTail(i) + } + + for (i <- 3 to 0 by -1) { + list.insertTail(i) + } + + list.insertTail(0) + + list.mkString() should equal("012332100") + assert(!list.isPalindrome()) + } + it should "be isPalindrome for large numbers" in { val list: SinglyLinkedList = new SinglyLinkedList() val num = 5000