summaryrefslogtreecommitdiff
path: root/basic/qa
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-03-20 18:43:58 +0000
committerNoel Power <noel.power@suse.com>2013-03-20 18:46:21 +0000
commitbc3a09997453a4aab39eeb5fe01aadf9fca0b485 (patch)
treea4147162a005a850e6da15ee90fcea01012cbfa1 /basic/qa
parentba4e2aad3eaf0102e52099bda2097dfc8082c3dd (diff)
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
Diffstat (limited to 'basic/qa')
-rw-r--r--basic/qa/basic_coverage/da-DK/cdbl.vb14
-rw-r--r--basic/qa/cppunit/basic_coverage.cxx44
2 files changed, 56 insertions, 2 deletions
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 000000000000..128cfcc9903d
--- /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 8d540e4a3820..ea2969a12cbf 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);