summaryrefslogtreecommitdiff
path: root/libs/pbd/test
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-14 16:52:19 +0200
committerRobin Gareus <robin@gareus.org>2016-07-14 16:52:43 +0200
commit311a5f1462c840ae7d6faa726e29f4a5429eda93 (patch)
tree9b8c1694eabb3b9ffcf07c1b2a5f810122077cd6 /libs/pbd/test
parent1970a8d4de6807278a28cb4a36f62854b044434a (diff)
add a natural sort algorithm
Diffstat (limited to 'libs/pbd/test')
-rw-r--r--libs/pbd/test/natsort_test.cc20
-rw-r--r--libs/pbd/test/natsort_test.h15
2 files changed, 35 insertions, 0 deletions
diff --git a/libs/pbd/test/natsort_test.cc b/libs/pbd/test/natsort_test.cc
new file mode 100644
index 0000000000..6e8d19b254
--- /dev/null
+++ b/libs/pbd/test/natsort_test.cc
@@ -0,0 +1,20 @@
+#include "natsort_test.h"
+#include "pbd/natsort.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION (NatSortTest);
+
+using namespace std;
+
+
+void
+NatSortTest::testBasic ()
+{
+ CPPUNIT_ASSERT (!PBD::naturally_less ("a32", "a4"));
+ CPPUNIT_ASSERT (!PBD::naturally_less ("a32", "a04"));
+ CPPUNIT_ASSERT ( PBD::naturally_less ("a32", "a40"));
+ CPPUNIT_ASSERT ( PBD::naturally_less ("a32a", "a32b"));
+ CPPUNIT_ASSERT (!PBD::naturally_less ("a32b", "a32a"));
+ CPPUNIT_ASSERT (!PBD::naturally_less ("abcd", "abc"));
+ CPPUNIT_ASSERT ( PBD::naturally_less ("abc", "abcd"));
+ CPPUNIT_ASSERT (!PBD::naturally_less ("abc", "abc"));
+}
diff --git a/libs/pbd/test/natsort_test.h b/libs/pbd/test/natsort_test.h
new file mode 100644
index 0000000000..7dea79a2f1
--- /dev/null
+++ b/libs/pbd/test/natsort_test.h
@@ -0,0 +1,15 @@
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class NatSortTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE (NatSortTest);
+ CPPUNIT_TEST (testBasic);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+ NatSortTest () { }
+ void testBasic ();
+
+private:
+};