MatthewRueben / sock-pairing

Try several sock pairing algorithms as an exercise in writing beautiful Java.
MIT License
0 stars 0 forks source link

Implement the "at the end" pairing algorithm. #3

Closed MatthewRueben closed 1 month ago

MatthewRueben commented 2 months ago
MatthewRueben commented 2 months ago

Brainstorm :: addressing the comodification error

MatthewRueben commented 2 months ago

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

MatthewRueben commented 2 months ago

Using log4j 2 for logging.

MatthewRueben commented 2 months ago

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

MatthewRueben commented 2 months ago

Re: testing that a certain exception is thrown under certain conditions, this seems to be the right answer.

MatthewRueben commented 1 month ago

Used this tutorial on Exceptions.

MatthewRueben commented 1 month ago

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

MatthewRueben commented 1 month ago

Used Assertions.assertThrows() from JUnit 5 for the test. 3685260