Add a test for PBD::copy_file using test files with utf-8 encoded filenames
authorTim Mayberry <mojofunk@gmail.com>
Wed, 25 Jun 2014 03:51:58 +0000 (13:51 +1000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Jun 2014 16:40:11 +0000 (12:40 -0400)
libs/pbd/test/filesystem_test.cc
libs/pbd/test/filesystem_test.h
libs/pbd/test/i18n_test/ardour.tst [new file with mode: 0644]
libs/pbd/test/i18n_test/žar.tst [new file with mode: 0644]
libs/pbd/test/i18n_test/пыл.tst [new file with mode: 0644]
libs/pbd/test/i18n_test/եռանդ.tst [new file with mode: 0644]
libs/pbd/test/i18n_test/ব্যগ্রতা.tst [new file with mode: 0644]
libs/pbd/test/i18n_test/ความกระตือรือร้น.tst [new file with mode: 0644]
libs/pbd/test/i18n_test/情熱.tst [new file with mode: 0644]
libs/pbd/test/i18n_test/热情.tst [new file with mode: 0644]

index 8a173858a053bb3e51f32bc8bbf36a7099ffd67d..8fe5afab21fa5b948d0c7248750e05805534d0a9 100644 (file)
@@ -10,6 +10,7 @@
 #include "test_common.h"
 
 using namespace std;
+using namespace PBD;
 
 CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest);
 
@@ -42,16 +43,44 @@ FilesystemTest::testPathIsWithin ()
 }
 
 void
-FilesystemTest::testCopyFile ()
+FilesystemTest::testCopyFileASCIIFilename ()
 {
-       std::string testdata_path;
+       string testdata_path;
        CPPUNIT_ASSERT (find_file (test_search_path (), "RosegardenPatchFile.xml", testdata_path));
 
-       std::string output_path = test_output_directory ("CopyFile");
+       string output_path = test_output_directory ("CopyFile");
 
        output_path = Glib::build_filename (output_path, "RosegardenPatchFile.xml");
 
+       cerr << endl;
        cerr << "CopyFile test output path: " << output_path << endl;
 
        CPPUNIT_ASSERT (PBD::copy_file (testdata_path, output_path));
 }
+
+void
+FilesystemTest::testCopyFileUTF8Filename ()
+{
+       vector<string> i18n_files;
+
+       Searchpath i18n_path(test_search_path());
+       i18n_path.add_subdirectory_to_paths("i18n_test");
+
+       PBD::find_files_matching_pattern (i18n_files, i18n_path, "*.tst");
+
+       cerr << endl;
+       cerr << "Copying " << i18n_files.size() << " test files from: "
+            << i18n_path.to_string () << endl;
+
+       for (vector<string>::iterator i = i18n_files.begin(); i != i18n_files.end(); ++i) {
+               string input_path = *i;
+               string output_file = Glib::path_get_basename(*i);
+               string output_path = test_output_directory ("CopyFile");
+               output_path = Glib::build_filename (output_path, output_file);
+
+               cerr << "Copying test file: " << input_path
+                    << " To " << output_path << endl;
+
+               CPPUNIT_ASSERT (PBD::copy_file (input_path, output_path));
+       }
+}
index f25d3abbc8639fe04a6908ea8874d8029320a959..a8b3968f3a4f55785b315df9d29b2bb1bc548917 100644 (file)
@@ -5,12 +5,14 @@ class FilesystemTest : public CppUnit::TestFixture
 {
        CPPUNIT_TEST_SUITE (FilesystemTest);
        CPPUNIT_TEST (testPathIsWithin);
-       CPPUNIT_TEST (testCopyFile);
+       CPPUNIT_TEST (testCopyFileASCIIFilename);
+       CPPUNIT_TEST (testCopyFileUTF8Filename);
        CPPUNIT_TEST_SUITE_END ();
 
 public:
        void testPathIsWithin ();
-       void testCopyFile ();
+       void testCopyFileASCIIFilename ();
+       void testCopyFileUTF8Filename ();
 
 };
 
diff --git a/libs/pbd/test/i18n_test/ardour.tst b/libs/pbd/test/i18n_test/ardour.tst
new file mode 100644 (file)
index 0000000..0c7afd2
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: English
diff --git a/libs/pbd/test/i18n_test/žar.tst b/libs/pbd/test/i18n_test/žar.tst
new file mode 100644 (file)
index 0000000..5d65515
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: Croatian
diff --git a/libs/pbd/test/i18n_test/пыл.tst b/libs/pbd/test/i18n_test/пыл.tst
new file mode 100644 (file)
index 0000000..fcc5b61
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: Russian
diff --git a/libs/pbd/test/i18n_test/եռանդ.tst b/libs/pbd/test/i18n_test/եռանդ.tst
new file mode 100644 (file)
index 0000000..09b97a7
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: Armenian
diff --git a/libs/pbd/test/i18n_test/ব্যগ্রতা.tst b/libs/pbd/test/i18n_test/ব্যগ্রতা.tst
new file mode 100644 (file)
index 0000000..86a4d2a
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: Bengali
diff --git a/libs/pbd/test/i18n_test/ความกระตือรือร้น.tst b/libs/pbd/test/i18n_test/ความกระตือรือร้น.tst
new file mode 100644 (file)
index 0000000..7ee6e18
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: Thai
diff --git a/libs/pbd/test/i18n_test/情熱.tst b/libs/pbd/test/i18n_test/情熱.tst
new file mode 100644 (file)
index 0000000..7d00918
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: Japanese
diff --git a/libs/pbd/test/i18n_test/热情.tst b/libs/pbd/test/i18n_test/热情.tst
new file mode 100644 (file)
index 0000000..571ba35
--- /dev/null
@@ -0,0 +1,2 @@
+Ardour Test file
+Language: Chinese (Simplified)