bump product version to 6.3.0.0.beta1
[LibreOffice.git] / dbaccess / qa / unit / firebird-regression.cxx
blob5474f48405d04ac132f9713647331286585a6ec2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "dbtest_base.cxx"
12 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
13 #include <com/sun/star/sdbc/XColumnLocate.hpp>
14 #include <com/sun/star/sdbc/XConnection.hpp>
15 #include <com/sun/star/sdbc/XResultSet.hpp>
16 #include <com/sun/star/sdbc/XRow.hpp>
17 #include <com/sun/star/sdbc/XStatement.hpp>
18 #include <svtools/miscopt.hxx>
19 #include <config_firebird.h>
21 using namespace ::com::sun::star;
22 using namespace ::com::sun::star::sdb;
23 using namespace ::com::sun::star::sdbc;
24 using namespace ::com::sun::star::uno;
26 class FirebirdTest
27 : public DBTestBase
29 public:
30 void testEmptyDBConnection();
31 void testIntegerDatabase();
33 CPPUNIT_TEST_SUITE(FirebirdTest);
34 CPPUNIT_TEST(testEmptyDBConnection);
35 CPPUNIT_TEST(testIntegerDatabase);
36 CPPUNIT_TEST_SUITE_END();
39 /**
40 * Test the loading of an "empty" file, i.e. the embedded database has not yet
41 * been initialised (as occurs when a new .odb is created and opened by base).
43 void FirebirdTest::testEmptyDBConnection()
45 #ifdef OSL_BIGENDIAN
46 auto const tmp = createTempCopy("firebird_empty_be.odb");
47 #else
48 auto const tmp = createTempCopy("firebird_empty_le.odb");
49 #endif
50 uno::Reference< XOfficeDatabaseDocument > xDocument =
51 getDocumentForUrl(tmp.GetURL());
53 getConnectionForDocument(xDocument);
55 closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
58 /**
59 * Test reading of integers from a known .odb to verify that the data
60 * can still be read on all systems.
62 void FirebirdTest::testIntegerDatabase()
64 #ifdef OSL_BIGENDIAN
65 uno::Reference< XOfficeDatabaseDocument > xDocument =
66 getDocumentForFileName("firebird_integer_be_ods12.odb");
67 #else
68 uno::Reference< XOfficeDatabaseDocument > xDocument =
69 getDocumentForFileName("firebird_integer_le_ods12.odb");
70 #endif
72 uno::Reference< XConnection > xConnection =
73 getConnectionForDocument(xDocument);
75 uno::Reference< XStatement > xStatement = xConnection->createStatement();
76 CPPUNIT_ASSERT(xStatement.is());
78 uno::Reference< XResultSet > xResultSet = xStatement->executeQuery(
79 "SELECT * FROM TESTTABLE");
80 CPPUNIT_ASSERT(xResultSet.is());
81 CPPUNIT_ASSERT(xResultSet->next());
83 uno::Reference< XRow > xRow(xResultSet, UNO_QUERY);
84 CPPUNIT_ASSERT(xRow.is());
85 uno::Reference< XColumnLocate > xColumnLocate(xRow, UNO_QUERY);
86 CPPUNIT_ASSERT(xColumnLocate.is());
88 CPPUNIT_ASSERT_EQUAL(sal_Int16(-30000),
89 xRow->getShort(xColumnLocate->findColumn("_SMALLINT")));
90 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2100000000),
91 xRow->getInt(xColumnLocate->findColumn("_INT")));
92 CPPUNIT_ASSERT_EQUAL(SAL_CONST_INT64(-9000000000000000000),
93 xRow->getLong(xColumnLocate->findColumn("_BIGINT")));
94 CPPUNIT_ASSERT_EQUAL(OUString("5"),
95 xRow->getString(xColumnLocate->findColumn("_CHAR")));
96 CPPUNIT_ASSERT_EQUAL(OUString("5"),
97 xRow->getString(xColumnLocate->findColumn("_VARCHAR")));
99 CPPUNIT_ASSERT(!xResultSet->next()); // Should only be one row
101 closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
104 CPPUNIT_TEST_SUITE_REGISTRATION(FirebirdTest);
106 CPPUNIT_PLUGIN_IMPLEMENT();
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */