[Libreoffice-commits] core.git: basic/CppunitTest_basic_coverage.mk basic/qa

Noel Power noel.power at suse.com
Wed Mar 20 11:50:20 PDT 2013


 basic/CppunitTest_basic_coverage.mk   |    1 
 basic/qa/basic_coverage/da-DK/cdbl.vb |   14 ++++++++++
 basic/qa/cppunit/basic_coverage.cxx   |   44 ++++++++++++++++++++++++++++++++--
 3 files changed, 57 insertions(+), 2 deletions(-)

New commits:
commit bc3a09997453a4aab39eeb5fe01aadf9fca0b485
Author: Noel Power <noel.power at suse.com>
Date:   Wed Mar 20 18:43:58 2013 +0000

    tweak basic_coverage test to support locale specific testing
    
    in basic some function results are influenced by locale, now
    in the basic_coverage directory you can have sub dirs ( named
    by the proper locale e.g. de-DE etc. ) and any macros found
    there will be run in the desired locale
    
    Change-Id: I625ee58d37493f83a15a62214bde6708e8fa75f7

diff --git a/basic/CppunitTest_basic_coverage.mk b/basic/CppunitTest_basic_coverage.mk
index 99aec22b..55906f5 100644
--- a/basic/CppunitTest_basic_coverage.mk
+++ b/basic/CppunitTest_basic_coverage.mk
@@ -33,6 +33,7 @@ $(eval $(call gb_CppunitTest_use_libraries,basic_coverage, \
     utl \
     vcl \
     xmlscript \
+    i18nisolang1 \
     $(gb_UWINAPI) \
 ))
 
diff --git a/basic/qa/basic_coverage/da-DK/cdbl.vb b/basic/qa/basic_coverage/da-DK/cdbl.vb
new file mode 100644
index 0000000..128cfcc
--- /dev/null
+++ b/basic/qa/basic_coverage/da-DK/cdbl.vb
@@ -0,0 +1,14 @@
+Function doUnitTest() as Integer
+    Dim A As String
+    Dim B As Double
+    Dim Expected As String
+    A = "222.222"
+    ' in da-DK locale ',' is the decimal separator
+    Expected = "222222"
+    B = Cdbl(A)
+    If B <> Expected Then
+        doUnitTest = 0
+    Else
+        doUnitTest = 1
+    End If
+End Function
diff --git a/basic/qa/cppunit/basic_coverage.cxx b/basic/qa/cppunit/basic_coverage.cxx
index 8d540e4..ea2969a 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -11,7 +11,8 @@
 #include <osl/file.hxx>
 #include "basic/sbmod.hxx"
 #include "basic/sbmeth.hxx"
-
+#include <i18npool/languagetag.hxx>
+#include <unotools/syslocaleoptions.hxx>
 
 namespace
 {
@@ -19,6 +20,7 @@ namespace
 class Coverage : public test::BootstrapFixture
 {
 private:
+    typedef std::vector< OUString > StringVec;
     int  m_nb_tests;
     int  m_nb_tests_ok;
     int  m_nb_tests_skipped;
@@ -29,6 +31,7 @@ private:
     void test_failed(void);
     void test_success(void);
     void print_summary() {};
+    StringVec get_subdirnames( const OUString& sDirName );
 
 public:
     Coverage();
@@ -101,6 +104,24 @@ void Coverage::run_test(OUString sFileURL)
     }
 }
 
+Coverage::StringVec Coverage::get_subdirnames( const OUString& sDirName )
+{
+    Coverage::StringVec sSubDirNames;
+    osl::Directory aDir(sDirName);
+    osl::DirectoryItem aItem;
+    osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+
+    if(osl::FileBase::E_None == aDir.open())
+    {
+        while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+        {
+            aItem.getFileStatus(aFileStatus);
+            if(aFileStatus.isDirectory())
+                sSubDirNames.push_back( aFileStatus.getFileURL() );
+        }
+    }
+    return sSubDirNames;
+}
 void Coverage::process_directory(OUString sDirName)
 {
     osl::Directory aDir(sDirName);
@@ -129,7 +150,26 @@ void Coverage::Coverage_Iterator(void)
     OUString sDirName = getURLFromSrc("/basic/qa/basic_coverage/");
 
     CPPUNIT_ASSERT(!sDirName.isEmpty());
-    process_directory(sDirName);
+    process_directory(sDirName); // any files in the root test dir are run in test harness default locale ( en-US )
+    Coverage::StringVec sLangDirs = get_subdirnames( sDirName );
+
+    for ( Coverage::StringVec::iterator it = sLangDirs.begin(), it_end = sLangDirs.end(); it != it_end; ++it )
+    {
+        OUString sDir( *it );
+        sal_Int32 nSlash = (*it).lastIndexOf('/');
+        if ( nSlash != -1 )
+        {
+            OUString sLangISO = sDir.copy( nSlash + 1 );
+            LanguageTag aLocale( sLangISO );
+            if ( aLocale.isValidBcp47() )
+            {
+                SvtSysLocaleOptions aLocalOptions;
+                // set locale for test dir
+                aLocalOptions.SetLocaleConfigString( sLangISO );
+                process_directory(sDir);
+            }
+        }
+    }
 }
 
   CPPUNIT_TEST_SUITE_REGISTRATION(Coverage);


More information about the Libreoffice-commits mailing list