Natural order Comparator project, with JUnit test suite and program source code in Git repository

This project demonstrates a natural order Comparator in Java.  Normally, Strings are compared character by character, but that is not the “natural” order humans usually expect.  Wikipedia has a good definition of natural order: “Natural sort order is an ordering of strings in alphabetical order, except that multi-digit numbers are ordered as a single character.”

NatOrderComparator/NatOrderComparator.java source code of class implementing the Comparator<String> interface.

com.wpollock.natordercomp.tests.NatOrderComparatorTestSuite.java source code of JUnit 4 test suite class.

View the Java doc (generated HTML) for the packages com.wpollock.natordercomp and com.wpollock.natordercomp.tests

You can also view the NatOrderComparator Git repo visualization and log.

In reality, developers must pick a small number of tests to implement, at least initially.  By using code coverage tools with your testing, you may find lots of code you didn't test.  That was the case here at first.  At the end, there is over 90% coverage, which is pretty good.

Over time, you will undoubtedly add addition test cases, as new features are enabled and new bugs are discovered.  Initially however, you should keep to a manageable number of test cases per unit.

Coverage of JUnit tests, using Eclipse “EclEmma” plug-in:

EclEmma Coverage Summary (in Eclipse IDE Project→Properties→Coverage Pane)
Shows code coverage summary pane (showing good coverage)

EclEmma Detail Pane (in Eclipse IDE)
Showing code coverage detail pane (showing over 99%)