Algorithms and OOD (CSC 207 2014S) : Assignments
This makeup is still in draft form.
A few of you had some significant problems on exam 2. Since there were unit tests for exam 2, I don't think that a makeup that simply asks you to correct your already buggy implementations is appropriate. I've also had very little luck with such makeup examinations. Hence, this makeup primarily asks you to reflect in new ways on a few issues from the examination.
Clone the repository at https://github.com/Grinnell-CSC207/makeup2-2014S.
As the examination suggested, I try to use some interesting approaches in my unit tests. For this problem, you need to explore and explain a few of those approaches. Your goal is to explain the approaches to someone who hasn't seen my code, but wants guidance in strategies for writing more sophisticated unit tests. You can treat them as if they are 'blog posts.
a. Explain how one might use factories in writing unit tests. You may need to teach yourself about factories in order to complete this problem.
b. Explain at least two ways in which one might use permutations in testing. For example, you might explain about randomized permutations and all permutations.
In the repository, you will find two implementations of filtered iterators, along with a skeletal set of unit tests. Both implementations passed my unit tests, but one has a large number of flaws. Your goal is to write a set of tests that will identify some of those flaws. (I believe that the good implementation is correct; you will get extra credit if you identify flaws in that implementation.) Your tests must illustrate the following flaws:
null, even when
nullis not in the underlying collection. Put a test that reveals this issue in
nextcorrectly returns some values in the underlying iterator and only returns values in the underlying iterator that meet the predicate, but fails to return the correct value for some of the calls to
next, rather than a flaw in
remove. Put a test that reveals this issue in
hasNext. Put a test that reveals this issue in
removeremove the wrong element (that is, something other than what was most recently returned by
next). Put a test that reveals this issue in
testRemove1. Note that the problem might be that the code calls
base.remove()when it should be throwing an exception.
hasNextreturn the wrong value (either
truewhen there should not be remaining elements, or
falsewhen there should be remaining elements). Put a test that reveals this issue in
Ideally, you will find that
BadFilteredIterator fails these five tests
(and passes the two sample tests) and that
all the tests.
Copyright (c) 2013-14 Samuel A. Rebelsky.
This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.