Add some very basic tests of Collator.
authorCarl Hetherington <cth@carlh.net>
Tue, 17 Jan 2023 16:20:57 +0000 (17:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 17 Jan 2023 16:20:57 +0000 (17:20 +0100)
test/collator_test.cc [new file with mode: 0644]
test/wscript

diff --git a/test/collator_test.cc b/test/collator_test.cc
new file mode 100644 (file)
index 0000000..fadc5f0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+    Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/collator.h"
+#include <boost/test/unit_test.hpp>
+
+
+BOOST_AUTO_TEST_CASE(collator_compare_works_and_ignores_case)
+{
+       Collator collator;
+
+       BOOST_CHECK_EQUAL(collator.compare("So often YOU won't even notice", "SO OFTEN you won't even NOTiCE"), 0);
+       BOOST_CHECK_EQUAL(collator.compare("So often YOU won't even notice", "SO OFTEN you won't even see"), -1);
+}
index e54d5c9852da268687ab52837ace35bdd909ffd8..5807d94ea9937f5dcc15d30d071b28d55a12b910 100644 (file)
@@ -60,6 +60,7 @@ def build(bld):
                  cinema_sound_processor_test.cc
                  client_server_test.cc
                  closed_caption_test.cc
+                 collator_test.cc
                  colour_conversion_test.cc
                  config_test.cc
                  content_test.cc