[Libreoffice-commits] .: 7 commits - sc/qa

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Sep 12 21:04:50 PDT 2011


 sc/qa/unit/filters-test.cxx |  125 ++++++++++++++++++++++----------------------
 1 file changed, 65 insertions(+), 60 deletions(-)

New commits:
commit 239ad92c2731d6f14349595475bdec7d1fe479ef
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Sep 12 23:59:46 2011 -0400

    We normally use an 'f' prefix for double.
    
    I'm not a big fan of Hungarian notation, but since we use it, let's
    be consistent.

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 96845b5..fdeb2c1 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -342,12 +342,12 @@ namespace {
 
 void testContentImpl(ScDocument* pDoc) //same code for ods, xls, xlsx
 {
-    double aValue;
+    double fValue;
     //check value import
-    pDoc->GetValue(0,0,0,aValue);
-    CPPUNIT_ASSERT_MESSAGE("value not imported correctly", aValue == 1);
-    pDoc->GetValue(0,1,0,aValue);
-    CPPUNIT_ASSERT_MESSAGE("value not imported correctly", aValue == 2);
+    pDoc->GetValue(0,0,0,fValue);
+    CPPUNIT_ASSERT_MESSAGE("value not imported correctly", fValue == 1);
+    pDoc->GetValue(0,1,0,fValue);
+    CPPUNIT_ASSERT_MESSAGE("value not imported correctly", fValue == 2);
     rtl::OUString aString;
     pDoc->GetString(1,0,0,aString);
     //check string import
@@ -355,14 +355,14 @@ void testContentImpl(ScDocument* pDoc) //same code for ods, xls, xlsx
     pDoc->GetString(1,1,0,aString);
     CPPUNIT_ASSERT_MESSAGE("string not imported correctly", aString == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("String2")));
     //check basic formula import
-    pDoc->GetValue(2,0,0,aValue);
-    CPPUNIT_ASSERT_MESSAGE("=2*3", aValue==6);
-    pDoc->GetValue(2,1,0,aValue);
-    CPPUNIT_ASSERT_MESSAGE("=2+3", aValue==5);
-    pDoc->GetValue(2,2,0,aValue);
-    CPPUNIT_ASSERT_MESSAGE("=2-3", aValue==-1);
-    pDoc->GetValue(2,3,0,aValue);
-    CPPUNIT_ASSERT_MESSAGE("=C1+C2", aValue==11);
+    pDoc->GetValue(2,0,0,fValue);
+    CPPUNIT_ASSERT_MESSAGE("=2*3", fValue == 6);
+    pDoc->GetValue(2,1,0,fValue);
+    CPPUNIT_ASSERT_MESSAGE("=2+3", fValue == 5);
+    pDoc->GetValue(2,2,0,fValue);
+    CPPUNIT_ASSERT_MESSAGE("=2-3", fValue == -1);
+    pDoc->GetValue(2,3,0,fValue);
+    CPPUNIT_ASSERT_MESSAGE("=C1+C2", fValue == 11);
     //check merged cells import
     SCCOL nCol = 4;
     SCROW nRow = 1;
commit a60b10593d206569acc315a32f1e6d66039bf863
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Sep 12 23:55:06 2011 -0400

    No need to use += to initialize m_aFileRoot.

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 569ec7d..96845b5 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -520,8 +520,8 @@ FiltersTest::FiltersTest()
     if (pSrcRoot[1] == ':')
         m_aSrcRoot += rtl::OUString::createFromAscii( "/" );
 #endif
-    m_aSrcRoot += rtl::OUString::createFromAscii( pSrcRoot );
-    m_aFileRoot += rtl::OUString::createFromAscii( pSrcRoot );
+    m_aFileRoot = rtl::OUString::createFromAscii( pSrcRoot );
+    m_aSrcRoot += m_aFileRoot;
 }
 
 void FiltersTest::setUp()
commit 8d74cabd80634187ceaea1f7d8c5b2b59eb21add
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Sep 12 23:44:59 2011 -0400

    Let's do hard re-calc only when necessary.
    
    Since doing a hard re-calc can be slow, let's not do this for all
    loading test cases, but only when we are testing formula interpretations.

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index e1941bd..569ec7d 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -192,8 +192,6 @@ ScDocShellRef FiltersTest::load(const rtl::OUString &rFilter, const rtl::OUStrin
     if (!xDocShRef->DoLoad(&aSrcMed))
         // load failed.
         xDocShRef.Clear();
-    else if (nFormat)
-        xDocShRef->DoHardRecalc(true);
 
     return xDocShRef;
 }
@@ -332,6 +330,7 @@ void FiltersTest::testRangeName()
         rtl::OUString aFilterType(aFileFormats[i].pTypeName, strlen(aFileFormats[i].pTypeName), RTL_TEXTENCODING_UTF8);
         std::cout << aFileFormats[i].pName << " Test" << std::endl;
         ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[i].nFormatType);
+        xDocSh->DoHardRecalc(true);
 
         CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-globals.*", xDocSh.Is());
         ScDocument* pDoc = xDocSh->GetDocument();
@@ -391,6 +390,7 @@ void FiltersTest::testContent()
         rtl::OUString aFilterType(aFileFormats[i].pTypeName, strlen(aFileFormats[i].pTypeName), RTL_TEXTENCODING_UTF8);
         std::cout << aFileFormats[i].pName << " Test" << std::endl;
         ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[i].nFormatType);
+        xDocSh->DoHardRecalc(true);
 
         CPPUNIT_ASSERT_MESSAGE("Failed to load universal-content.*", xDocSh.Is());
         ScDocument* pDoc = xDocSh->GetDocument();
@@ -408,6 +408,7 @@ void FiltersTest::testFunctions()
     rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8);
     std::cout << aFileFormats[0].pName << " Test" << std::endl;
     ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[0].nFormatType);
+    xDocSh->DoHardRecalc(true);
 
     CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is());
     ScDocument* pDoc = xDocSh->GetDocument();
commit 0544af5f11ae71fb9c553bc04aa1dbbd98da440d
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Sep 12 23:36:53 2011 -0400

    Let's put using namespace declarations at the top.

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 843b85b..e1941bd 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -76,6 +76,8 @@ const int indeterminate = 2;
 #define XLS_FORMAT_TYPE 318767171
 #define XLSX_FORMAT_TYPE 268959811
 
+using namespace ::com::sun::star;
+
 namespace {
 
 struct FileFormat {
@@ -123,9 +125,6 @@ void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab)
 
 }
 
-
-using namespace ::com::sun::star;
-
 /* Implementation of Filters test */
 
 class FiltersTest : public CppUnit::TestFixture
commit e15718c41d9afedf1557cae20298befdf464ca30
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Sep 12 23:34:27 2011 -0400

    It's appropriate to name this class singular.
    
    Since each instance refers to a single file format, while its array
    instance holds multiple instances of this structure.

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 3c06e73..843b85b 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -78,11 +78,11 @@ const int indeterminate = 2;
 
 namespace {
 
-struct FileFormats {
+struct FileFormat {
     const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
 };
 
-FileFormats aFileFormats[] = {
+FileFormat aFileFormats[] = {
     { "ods" , "calc8", "", ODS_FORMAT_TYPE },
     { "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_FORMAT_TYPE },
     { "xlsx", "Calc MS Excel 2007 XML" , "MS Excel 2007 XML", XLSX_FORMAT_TYPE }
commit 5440aa1e37b483d54fd44fe448cf57449bf6e42b
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Sep 12 23:33:31 2011 -0400

    Let's not indent in namespace scopes.

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 956e989..3c06e73 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -78,49 +78,48 @@ const int indeterminate = 2;
 
 namespace {
 
+struct FileFormats {
+    const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
+};
 
-    struct FileFormats {
-        const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
-    };
+FileFormats aFileFormats[] = {
+    { "ods" , "calc8", "", ODS_FORMAT_TYPE },
+    { "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_FORMAT_TYPE },
+    { "xlsx", "Calc MS Excel 2007 XML" , "MS Excel 2007 XML", XLSX_FORMAT_TYPE }
+};
 
-    FileFormats aFileFormats[] = {
-        { "ods" , "calc8", "", ODS_FORMAT_TYPE },
-        { "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_FORMAT_TYPE },
-        { "xlsx", "Calc MS Excel 2007 XML" , "MS Excel 2007 XML", XLSX_FORMAT_TYPE }
-    };
+void loadFile(const rtl::OUString& aFileName, std::string& aContent)
+{
+    rtl::OString aOFileName = rtl::OUStringToOString(aFileName, RTL_TEXTENCODING_UTF8);
+    std::ifstream aFile(aOFileName.getStr());
+
+    CPPUNIT_ASSERT_MESSAGE("could not open csv file", aFile);
+    std::ostringstream aOStream;
+    aOStream << aFile.rdbuf();
+    aFile.close();
+    aContent = aOStream.str();
+}
 
-    void loadFile(const rtl::OUString& aFileName, std::string& aContent)
+void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab)
+{
+    csv_handler aHandler(pDoc, nTab);
+    orcus::csv_parser_config aConfig;
+    aConfig.delimiters.push_back(',');
+    aConfig.delimiters.push_back(';');
+    aConfig.text_qualifier = '"';
+    std::string aContent;
+    loadFile(aFileName, aContent);
+    orcus::csv_parser<csv_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig);
+    try
     {
-        rtl::OString aOFileName = rtl::OUStringToOString(aFileName, RTL_TEXTENCODING_UTF8);
-        std::ifstream aFile(aOFileName.getStr());
-
-        CPPUNIT_ASSERT_MESSAGE("could not open csv file", aFile);
-        std::ostringstream aOStream;
-        aOStream << aFile.rdbuf();
-        aFile.close();
-        aContent = aOStream.str();
+        parser.parse();
     }
-
-    void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab)
+    catch (const orcus::csv_parse_error& e)
     {
-        csv_handler aHandler(pDoc, nTab);
-        orcus::csv_parser_config aConfig;
-        aConfig.delimiters.push_back(',');
-        aConfig.delimiters.push_back(';');
-        aConfig.text_qualifier = '"';
-        std::string aContent;
-        loadFile(aFileName, aContent);
-        orcus::csv_parser<csv_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig);
-        try
-        {
-            parser.parse();
-        }
-        catch (const orcus::csv_parse_error& e)
-        {
-            std::cout << "reading csv content file failed" << e.what() << std::endl;
-            CPPUNIT_ASSERT_MESSAGE("csv parser error", false);
-        }
+        std::cout << "reading csv content file failed" << e.what() << std::endl;
+        CPPUNIT_ASSERT_MESSAGE("csv parser error", false);
     }
+}
 
 }
 
commit efebf5181c40c8ff85185b91d46ac356f8127089
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Sep 12 23:30:51 2011 -0400

    These don't have to be member functions.

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 464cbff..956e989 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -151,9 +151,7 @@ public:
 
     //ods filter tests
     void testRangeName();
-    void testRangeNameImpl(ScDocument* pDoc);
     void testContent();
-    void testContentImpl(ScDocument* pDoc); //same code for ods, xls, xlsx
     void testFunctions();
     void testBugFixesODS();
     void testBugFixesXLS();
@@ -291,7 +289,9 @@ void FiltersTest::testCVEs()
 
 }
 
-void FiltersTest::testRangeNameImpl(ScDocument* pDoc)
+namespace {
+
+void testRangeNameImpl(ScDocument* pDoc)
 {
     //check one range data per sheet and one global more detailed
     //add some more checks here
@@ -319,6 +319,8 @@ void FiltersTest::testRangeNameImpl(ScDocument* pDoc)
     CPPUNIT_ASSERT_MESSAGE("range name Sheet2.local1 should reference Sheet1.A5", aValue == 5);
 }
 
+}
+
 void FiltersTest::testRangeName()
 {
     const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("named-ranges-global."));
@@ -339,7 +341,9 @@ void FiltersTest::testRangeName()
     }
 }
 
-void FiltersTest::testContentImpl(ScDocument* pDoc)
+namespace {
+
+void testContentImpl(ScDocument* pDoc) //same code for ods, xls, xlsx
 {
     double aValue;
     //check value import
@@ -375,6 +379,8 @@ void FiltersTest::testContentImpl(ScDocument* pDoc)
     //add additional checks here
 }
 
+}
+
 void FiltersTest::testContent()
 {
     const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("universal-content."));


More information about the Libreoffice-commits mailing list