From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- dbaccess/qa/unit/tdf126268.cxx | 89 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 dbaccess/qa/unit/tdf126268.cxx (limited to 'dbaccess/qa/unit/tdf126268.cxx') diff --git a/dbaccess/qa/unit/tdf126268.cxx b/dbaccess/qa/unit/tdf126268.cxx new file mode 100644 index 000000000..b0719936f --- /dev/null +++ b/dbaccess/qa/unit/tdf126268.cxx @@ -0,0 +1,89 @@ +/* -*- 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 +#include +#include +#include +#include + +class Tdf126268Test : public DBTestBase +{ +public: + void testNumbers(); + + virtual void setUp() override; + + CPPUNIT_TEST_SUITE(Tdf126268Test); + + CPPUNIT_TEST(testNumbers); + + CPPUNIT_TEST_SUITE_END(); +}; + +void Tdf126268Test::setUp() +{ + DBTestBase::setUp(); + osl_setEnvironment(OUString{ "DBACCESS_HSQL_MIGRATION" }.pData, OUString{ "1" }.pData); +} + +namespace +{ +struct expect_t +{ + sal_Int16 id; + OUString number; +}; +} + +static const expect_t expect[] = { + { 1, "0.00" }, { 2, "25.00" }, { 3, "26.00" }, { 4, "30.4" }, { 5, "45.8" }, + { 6, "-25.00" }, { 7, "-26.00" }, { 8, "-30.4" }, { 9, "-45.8" }, +}; + +void Tdf126268Test::testNumbers() +{ + SvtMiscOptions aMiscOptions; + bool oldValue = aMiscOptions.IsExperimentalMode(); + + aMiscOptions.SetExperimentalMode(true); + + // the migration requires the file to be writable + utl::TempFile const temp(createTempCopy("tdf126268.odb")); + uno::Reference const xDocument = getDocumentForUrl(temp.GetURL()); + + uno::Reference xConnection = getConnectionForDocument(xDocument); + + // select basically everything from the .odb + uno::Reference statement = xConnection->createStatement(); + const OUString sql{ "SELECT ID, Column1, Column2 FROM tableTest ORDER BY ID" }; + + uno::Reference xRes = statement->executeQuery(sql); + uno::Reference xRow(xRes, UNO_QUERY_THROW); + + // check result + for (auto& e : expect) + { + CPPUNIT_ASSERT(xRes->next()); + CPPUNIT_ASSERT_EQUAL(e.id, xRow->getShort(1)); + CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(2)); //decimal + CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(3)); //numeric + } + CPPUNIT_ASSERT(!xRes->next()); + + closeDocument(uno::Reference(xDocument, uno::UNO_QUERY)); + if (!oldValue) + aMiscOptions.SetExperimentalMode(false); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Tdf126268Test); + +CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit v1.2.3