Closed MatthewRueben closed 1 month ago
Spliterator
to get an iterator over a sublist, but the documentation says not to use mutable sources. Re: that comodification error, I ended up just using the same Iterator
but reset it to the start of the List
at the beginning of each outer loop. https://github.com/MatthewRueben/sock-pairing/commit/0dc2a16307845f7524aa28a898261cd92762fe47
Using log4j 2 for logging.
Sounds like programmatically setting the log4j2 logging level isn't very pretty, and the recommended thing to do is to use the configuration file. The good news is, I can use a log4j2-test configuration file that will get used for unit tests, and a log4j2 configuration file that will get used otherwise. That way I can specify two levels.
Done, and unit testing is now set up: https://github.com/MatthewRueben/sock-pairing/commit/9d779653558e4af0b3173e785ff0ec7330a4abe9
Re: testing that a certain exception is thrown under certain conditions, this seems to be the right answer.
Used this tutorial on Exceptions.
Ended up having my new custom NoMatchRemainingException
extend RuntimeException
so I don't have to check for it because this would be a user error -- namely, passing in a list of objects for which there are not 2 (or 0, 4, 6, ...) of each. 0a985bd
Used Assertions.assertThrows()
from JUnit 5 for the test. 3685260
Iterator
s over the sameList
.