deque. Write one or more tests for [isEmpty and [size]. Run them and verify that they fail. Your test(s) shou verify more than one interesting case, such as checking both an empty and a nonempty list, or chec that the size changes. For thos

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write tests and implementation for size and is empty 

isEmpty and size
These two methods must take constant time. That is, the time it takes to for either method to finish
execution should not depend on how many elements are in the deque.
Write one or more tests for isEmpty and size. Run them and verify that they fail. Your test(s) should
verify more than one interesting case, such as checking both an empty and a nonempty list, or checkin
that the size changes.
For these tests, you can use the isTrue or isFalse methods on your assertThat statements.
Your tests can range from very fine-grained, e.g. testIsEmpty
coarse grained, e.g. [testSizeAndIsEmpty. It's up to you to explore and find what granularity you prefer.
testSizeZero testSizeOne to very
Task: Write tests for tho
9
Transcribed Image Text:isEmpty and size These two methods must take constant time. That is, the time it takes to for either method to finish execution should not depend on how many elements are in the deque. Write one or more tests for isEmpty and size. Run them and verify that they fail. Your test(s) should verify more than one interesting case, such as checking both an empty and a nonempty list, or checkin that the size changes. For these tests, you can use the isTrue or isFalse methods on your assertThat statements. Your tests can range from very fine-grained, e.g. testIsEmpty coarse grained, e.g. [testSizeAndIsEmpty. It's up to you to explore and find what granularity you prefer. testSizeZero testSizeOne to very Task: Write tests for tho 9
Expert Solution
Step 1
  1. Import two packages 'org.junit.Assert'  and 'org.junit.jupiter.api.Test' where  'org.junit.Assert' is static.
  2. Declare a class named 'Deque_test'
  3. Declare five methods in the class- testIsEmpty(),testIsEmpty_One(),testIsEmpty_Three(),testSizeZero(),testSizeTwo(),testSizeMultipe()
  4. Use @Test to annotate these methods as test methods or test cases which can be used for testing.
  5. Method testIsEmpty() contains a declaration of empty deque data structure and method assertFalse(deque.isEmpty()) is used to check if deque.isEmpty() function to return false.
  6. Method testIsEmpty_One() contains a declaration of empty deque data structure. An element '1' is added to the deque using the addLast() method in the deque. It also contains a method assertTrue(deque.isEmpty()) is used to check if deque.isEmpty() function to return true.
  7. Method testIsEmpty_Three() contains a declaration of empty deque data structure named 'deque' of integer type. Three elements 1,2,13 are added to the deque using the addLast() method in the deque. It also contains a method assertTrue(deque.isEmpty()) is used to check if deque.isEmpty() function to return true.
  8. Method testSizeZero() contains a declaration of empty deque data structure named 'deque' of integer type. And a method assertFalse(deque.size() == 0) which is used to check if deque.size() == 0 value returns false.
  9. Method testSizeTwo() contains a declaration of empty deque data structure named 'deque' of integer type. Two elements 1,2 are added to the deque using the addLast() method in the deque. And a method assertFalse(deque.size() == 2) which is used to check if deque.size() == 2 value returns false.
  10. Method testSizeMultiple() contains a declaration of empty deque data structure named 'deque' of integer type. Three elements 1,2,3 are added to the deque using the addLast() method in the deque. And a method assertFalse(deque.size() == 3) which is used to check if deque.size() == 3 value returns false.
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Threads in linked list
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education