diff options
author | Rene Engelhard <rene@debian.org> | 2018-09-23 19:40:59 +0200 |
---|---|---|
committer | Rene Engelhard <rene@debian.org> | 2018-10-03 10:13:31 +0200 |
commit | 36befb3aca96907a14e71e82497dbb8f03ead5ab (patch) | |
tree | eda55b352de92ded974fd9c0885d178fce059938 /dbaccess/qa/unit | |
parent | f104b3cafee63b47a735cfdce0f05dab2eedbb91 (diff) |
tdf#72987 split firebird test into a regression test and a "new" test
former with endianness and latter with the new fbk format.
Add new endianness-independent firebird test odbs
Change-Id: I29be2e6916fcca74744211dba04463376fb6b8d5
Reviewed-on: https://gerrit.libreoffice.org/60917
Reviewed-by: Rene Engelhard <rene@debian.org>
Tested-by: Rene Engelhard <rene@debian.org>
Diffstat (limited to 'dbaccess/qa/unit')
-rw-r--r-- | dbaccess/qa/unit/data/firebird_empty.odb | bin | 0 -> 2148 bytes | |||
-rw-r--r-- | dbaccess/qa/unit/data/firebird_integer_ods12.odb | bin | 0 -> 77617 bytes | |||
-rw-r--r-- | dbaccess/qa/unit/firebird-regression.cxx | 108 | ||||
-rw-r--r-- | dbaccess/qa/unit/firebird.cxx | 12 |
4 files changed, 110 insertions, 10 deletions
diff --git a/dbaccess/qa/unit/data/firebird_empty.odb b/dbaccess/qa/unit/data/firebird_empty.odb Binary files differnew file mode 100644 index 000000000000..9aabfd47b059 --- /dev/null +++ b/dbaccess/qa/unit/data/firebird_empty.odb diff --git a/dbaccess/qa/unit/data/firebird_integer_ods12.odb b/dbaccess/qa/unit/data/firebird_integer_ods12.odb Binary files differnew file mode 100644 index 000000000000..642b038dd78b --- /dev/null +++ b/dbaccess/qa/unit/data/firebird_integer_ods12.odb diff --git a/dbaccess/qa/unit/firebird-regression.cxx b/dbaccess/qa/unit/firebird-regression.cxx new file mode 100644 index 000000000000..5474f48405d0 --- /dev/null +++ b/dbaccess/qa/unit/firebird-regression.cxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "dbtest_base.cxx" + +#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XStatement.hpp> +#include <svtools/miscopt.hxx> +#include <config_firebird.h> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +class FirebirdTest + : public DBTestBase +{ +public: + void testEmptyDBConnection(); + void testIntegerDatabase(); + + CPPUNIT_TEST_SUITE(FirebirdTest); + CPPUNIT_TEST(testEmptyDBConnection); + CPPUNIT_TEST(testIntegerDatabase); + CPPUNIT_TEST_SUITE_END(); +}; + +/** + * Test the loading of an "empty" file, i.e. the embedded database has not yet + * been initialised (as occurs when a new .odb is created and opened by base). + */ +void FirebirdTest::testEmptyDBConnection() +{ +#ifdef OSL_BIGENDIAN + auto const tmp = createTempCopy("firebird_empty_be.odb"); +#else + auto const tmp = createTempCopy("firebird_empty_le.odb"); +#endif + uno::Reference< XOfficeDatabaseDocument > xDocument = + getDocumentForUrl(tmp.GetURL()); + + getConnectionForDocument(xDocument); + + closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY)); +} + +/** + * Test reading of integers from a known .odb to verify that the data + * can still be read on all systems. + */ +void FirebirdTest::testIntegerDatabase() +{ +#ifdef OSL_BIGENDIAN + uno::Reference< XOfficeDatabaseDocument > xDocument = + getDocumentForFileName("firebird_integer_be_ods12.odb"); +#else + uno::Reference< XOfficeDatabaseDocument > xDocument = + getDocumentForFileName("firebird_integer_le_ods12.odb"); +#endif + + uno::Reference< XConnection > xConnection = + getConnectionForDocument(xDocument); + + uno::Reference< XStatement > xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + + uno::Reference< XResultSet > xResultSet = xStatement->executeQuery( + "SELECT * FROM TESTTABLE"); + CPPUNIT_ASSERT(xResultSet.is()); + CPPUNIT_ASSERT(xResultSet->next()); + + uno::Reference< XRow > xRow(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT(xRow.is()); + uno::Reference< XColumnLocate > xColumnLocate(xRow, UNO_QUERY); + CPPUNIT_ASSERT(xColumnLocate.is()); + + CPPUNIT_ASSERT_EQUAL(sal_Int16(-30000), + xRow->getShort(xColumnLocate->findColumn("_SMALLINT"))); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-2100000000), + xRow->getInt(xColumnLocate->findColumn("_INT"))); + CPPUNIT_ASSERT_EQUAL(SAL_CONST_INT64(-9000000000000000000), + xRow->getLong(xColumnLocate->findColumn("_BIGINT"))); + CPPUNIT_ASSERT_EQUAL(OUString("5"), + xRow->getString(xColumnLocate->findColumn("_CHAR"))); + CPPUNIT_ASSERT_EQUAL(OUString("5"), + xRow->getString(xColumnLocate->findColumn("_VARCHAR"))); + + CPPUNIT_ASSERT(!xResultSet->next()); // Should only be one row + + closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY)); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(FirebirdTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/qa/unit/firebird.cxx b/dbaccess/qa/unit/firebird.cxx index 610caf69d785..c3652b7debd1 100644 --- a/dbaccess/qa/unit/firebird.cxx +++ b/dbaccess/qa/unit/firebird.cxx @@ -42,11 +42,7 @@ public: */ void FirebirdTest::testEmptyDBConnection() { -#ifdef OSL_BIGENDIAN -// FIXME -#else - auto const tmp = createTempCopy("firebird_empty_le.odb"); -#endif + auto const tmp = createTempCopy("firebird_empty.odb"); uno::Reference< XOfficeDatabaseDocument > xDocument = getDocumentForUrl(tmp.GetURL()); @@ -61,12 +57,8 @@ void FirebirdTest::testEmptyDBConnection() */ void FirebirdTest::testIntegerDatabase() { -#ifdef OSL_BIGENDIAN -// FIXME -#else uno::Reference< XOfficeDatabaseDocument > xDocument = - getDocumentForFileName("firebird_integer_le_ods12.odb"); -#endif + getDocumentForFileName("firebird_integer_ods12.odb"); uno::Reference< XConnection > xConnection = getConnectionForDocument(xDocument); |