From 53c959ad8f75b4d5c394e091d94e22feb63cb23d Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 25 Jun 2014 13:51:58 +1000 Subject: [PATCH] Add a test for PBD::copy_file using test files with utf-8 encoded filenames --- libs/pbd/test/filesystem_test.cc | 35 +++++++++++++++++-- libs/pbd/test/filesystem_test.h | 6 ++-- libs/pbd/test/i18n_test/ardour.tst | 2 ++ libs/pbd/test/i18n_test/žar.tst | 2 ++ libs/pbd/test/i18n_test/пыл.tst | 2 ++ libs/pbd/test/i18n_test/եռանդ.tst | 2 ++ .../i18n_test/ব্যগ্রতা.tst | 2 ++ ...กระตือรือร้น.tst | 2 ++ libs/pbd/test/i18n_test/情熱.tst | 2 ++ libs/pbd/test/i18n_test/热情.tst | 2 ++ 10 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 libs/pbd/test/i18n_test/ardour.tst create mode 100644 libs/pbd/test/i18n_test/žar.tst create mode 100644 libs/pbd/test/i18n_test/пыл.tst create mode 100644 libs/pbd/test/i18n_test/եռանդ.tst create mode 100644 libs/pbd/test/i18n_test/ব্যগ্রতা.tst create mode 100644 libs/pbd/test/i18n_test/ความกระตือรือร้น.tst create mode 100644 libs/pbd/test/i18n_test/情熱.tst create mode 100644 libs/pbd/test/i18n_test/热情.tst diff --git a/libs/pbd/test/filesystem_test.cc b/libs/pbd/test/filesystem_test.cc index 8a173858a0..8fe5afab21 100644 --- a/libs/pbd/test/filesystem_test.cc +++ b/libs/pbd/test/filesystem_test.cc @@ -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 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::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)); + } +} diff --git a/libs/pbd/test/filesystem_test.h b/libs/pbd/test/filesystem_test.h index f25d3abbc8..a8b3968f3a 100644 --- a/libs/pbd/test/filesystem_test.h +++ b/libs/pbd/test/filesystem_test.h @@ -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 index 0000000000..0c7afd2838 --- /dev/null +++ b/libs/pbd/test/i18n_test/ardour.tst @@ -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 index 0000000000..5d65515a01 --- /dev/null +++ b/libs/pbd/test/i18n_test/žar.tst @@ -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 index 0000000000..fcc5b61f0c --- /dev/null +++ b/libs/pbd/test/i18n_test/пыл.tst @@ -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 index 0000000000..09b97a757f --- /dev/null +++ b/libs/pbd/test/i18n_test/եռանդ.tst @@ -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 index 0000000000..86a4d2aae4 --- /dev/null +++ b/libs/pbd/test/i18n_test/ব্যগ্রতা.tst @@ -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 index 0000000000..7ee6e18ac8 --- /dev/null +++ b/libs/pbd/test/i18n_test/ความกระตือรือร้น.tst @@ -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 index 0000000000..7d00918c94 --- /dev/null +++ b/libs/pbd/test/i18n_test/情熱.tst @@ -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 index 0000000000..571ba353df --- /dev/null +++ b/libs/pbd/test/i18n_test/热情.tst @@ -0,0 +1,2 @@ +Ardour Test file +Language: Chinese (Simplified)