LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/connectivity/qa/connectivity/commontools - FValue_test.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 163 163 100.0 %
Date: 2013-07-09 Functions: 20 21 95.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <test/bootstrapfixture.hxx>
      21             : 
      22             : #include "connectivity/FValue.hxx"
      23             : using namespace ::com::sun::star::uno;
      24             : 
      25             : namespace connectivity { namespace commontools {
      26             : 
      27          22 : class FValueTest: public test::BootstrapFixture
      28             : {
      29             : public:
      30          11 :     FValueTest() : test::BootstrapFixture(false, false) {};
      31             : 
      32             :     void test_Bool();
      33             : 
      34             :     void test_Int8();
      35             :     void test_uInt8();
      36             : 
      37             :     void test_Int16();
      38             :     void test_uInt16();
      39             : 
      40             :     void test_Int32();
      41             :     void test_uInt32();
      42             : 
      43             :     void test_Int64();
      44             :     void test_uInt64();
      45             : 
      46             :     void test_float();
      47             :     void test_double();
      48             : 
      49           2 :     CPPUNIT_TEST_SUITE(FValueTest);
      50             : 
      51           1 :     CPPUNIT_TEST(test_Bool);
      52             : 
      53           1 :     CPPUNIT_TEST(test_Int8);
      54           1 :     CPPUNIT_TEST(test_uInt8);
      55             : 
      56           1 :     CPPUNIT_TEST(test_Int16);
      57           1 :     CPPUNIT_TEST(test_uInt16);
      58             : 
      59           1 :     CPPUNIT_TEST(test_Int32);
      60           1 :     CPPUNIT_TEST(test_uInt32);
      61             : 
      62           1 :     CPPUNIT_TEST(test_Int64);
      63           1 :     CPPUNIT_TEST(test_uInt64);
      64             : 
      65           1 :     CPPUNIT_TEST(test_float);
      66           1 :     CPPUNIT_TEST(test_double);
      67             : 
      68           2 :     CPPUNIT_TEST_SUITE_END();
      69             : };
      70             : 
      71           1 : void FValueTest::test_Bool()
      72             : {
      73           1 :     bool src_Bool = true;
      74           1 :     ORowSetValue v(src_Bool);
      75           1 :     bool trg_Bool = v.getBool();
      76             : 
      77           1 :     std::cerr << "src_Bool: " << src_Bool << std::endl;
      78           1 :     std::cerr << "trg_Bool: " << trg_Bool << std::endl;
      79             : 
      80           1 :     CPPUNIT_ASSERT_MESSAGE("bool conversion to ORowSetValue didn't work", src_Bool == trg_Bool);
      81             : 
      82           2 :     Any any_Bool = v.makeAny();
      83           2 :     ORowSetValue t;
      84           1 :     t.fill(any_Bool);
      85           1 :     trg_Bool = t.getBool();
      86             : 
      87           1 :     std::cerr << "trg_Bool: " << trg_Bool << std::endl;
      88             : 
      89           2 :     CPPUNIT_ASSERT_MESSAGE("bool conversion from Any didn't work", src_Bool == trg_Bool);
      90           1 : }
      91             : 
      92           1 : void FValueTest::test_Int8()
      93             : {
      94           1 :     sal_Int8 src_salInt8 = 127;
      95           1 :     ORowSetValue v(src_salInt8);
      96           1 :     sal_Int8 trg_salInt8 = v.getInt8();
      97             : 
      98           1 :     std::cerr << "src_salInt8: " << static_cast<short>(src_salInt8) << std::endl;
      99           1 :     std::cerr << "trg_salInt8: " << static_cast<short>(trg_salInt8) << std::endl;
     100             : 
     101           1 :     CPPUNIT_ASSERT_MESSAGE("sal_Int8 conversion to ORowSetValue didn't work", src_salInt8 == trg_salInt8);
     102             : 
     103           2 :     Any any_Int8 = v.makeAny();
     104           2 :     ORowSetValue t;
     105           1 :     t.fill(any_Int8);
     106           1 :     trg_salInt8 = t.getInt8();
     107             : 
     108           1 :     std::cerr << "trg_salInt8: " << static_cast<short>(trg_salInt8) << std::endl;
     109             : 
     110           2 :     CPPUNIT_ASSERT_MESSAGE("sal_Int8 conversion from Any didn't work", src_salInt8 == trg_salInt8);
     111           1 : }
     112             : 
     113           1 : void FValueTest::test_uInt8()
     114             : {
     115           1 :     sal_uInt8 src_saluInt8 = 255;
     116           1 :     ORowSetValue v(src_saluInt8);
     117           1 :     sal_uInt8 trg_saluInt8 = v.getUInt8();
     118             : 
     119           1 :     std::cerr << "src_saluInt8: " << static_cast<short>(src_saluInt8) << std::endl;
     120           1 :     std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
     121             : 
     122           1 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt8 conversion to ORowSetValue didn't work", src_saluInt8 == trg_saluInt8);
     123             : 
     124           2 :     Any any_uInt8 = v.makeAny();
     125           2 :     ORowSetValue t;
     126           1 :     t.fill(any_uInt8);
     127           1 :     trg_saluInt8 = t.getUInt8();
     128             : 
     129           1 :     std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
     130             : 
     131           2 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt8 conversion from Any didn't work", src_saluInt8 == trg_saluInt8);
     132           1 : }
     133             : 
     134           1 : void FValueTest::test_Int16()
     135             : {
     136           1 :     sal_Int16 src_salInt16 = -10001;
     137           1 :     ORowSetValue v(src_salInt16);
     138           1 :     sal_Int16 trg_salInt16 = v.getInt16();
     139             : 
     140           1 :     std::cerr << "src_salInt16: " << src_salInt16 << std::endl;
     141           1 :     std::cerr << "trg_salInt16: " << trg_salInt16 << std::endl;
     142             : 
     143           1 :     CPPUNIT_ASSERT_MESSAGE("sal_Int16 conversion to ORowSetValue didn't work", src_salInt16 == trg_salInt16);
     144             : 
     145           2 :     Any any_Int16 = v.makeAny();
     146           2 :     ORowSetValue t;
     147           1 :     t.fill(any_Int16);
     148           1 :     trg_salInt16 = t.getInt16();
     149             : 
     150           2 :     CPPUNIT_ASSERT_MESSAGE("sal_Int16 conversion from Any didn't work", src_salInt16 == trg_salInt16);
     151           1 : }
     152             : 
     153           1 : void FValueTest::test_uInt16()
     154             : {
     155           1 :     sal_uInt16 src_saluInt16 = 10001;
     156           1 :     ORowSetValue v(src_saluInt16);
     157           1 :     sal_uInt16 trg_saluInt16 = v.getUInt16();
     158             : 
     159           1 :     std::cerr << "src_saluInt16: " << src_saluInt16 << std::endl;
     160           1 :     std::cerr << "trg_saluInt16: " << trg_saluInt16 << std::endl;
     161             : 
     162           1 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt16 conversion to ORowSetValue didn't work", src_saluInt16 == trg_saluInt16);
     163             : 
     164           2 :     Any any_uInt16 = v.makeAny();
     165           2 :     ORowSetValue t;
     166           1 :     t.fill(any_uInt16);
     167           1 :     trg_saluInt16 = t.getUInt16();
     168             : 
     169           2 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt16 conversion from Any didn't work", src_saluInt16 == trg_saluInt16);
     170           1 : }
     171             : 
     172           1 : void FValueTest::test_Int32()
     173             : {
     174           1 :     sal_Int32 src_salInt32 = -10000001;
     175           1 :     ORowSetValue v(src_salInt32);
     176           1 :     sal_Int32 trg_salInt32 = v.getInt32();
     177             : 
     178           1 :     std::cerr << "src_salInt32: " << src_salInt32 << std::endl;
     179           1 :     std::cerr << "trg_salInt32: " << trg_salInt32 << std::endl;
     180             : 
     181           1 :     CPPUNIT_ASSERT_MESSAGE("sal_Int32 conversion to ORowSetValue didn't work", src_salInt32 == trg_salInt32);
     182             : 
     183           2 :     Any any_Int32 = v.makeAny();
     184           2 :     ORowSetValue t;
     185           1 :     t.fill(any_Int32);
     186           1 :     trg_salInt32 = t.getInt32();
     187             : 
     188           2 :     CPPUNIT_ASSERT_MESSAGE("sal_Int32 conversion from Any didn't work", src_salInt32 == trg_salInt32);
     189           1 : }
     190             : 
     191           1 : void FValueTest::test_uInt32()
     192             : {
     193           1 :     sal_uInt32 src_saluInt32 = 100000001;
     194           1 :     ORowSetValue v(src_saluInt32);
     195           1 :     sal_uInt32 trg_saluInt32 = v.getUInt32();
     196             : 
     197           1 :     std::cerr << "src_saluInt32: " << src_saluInt32 << std::endl;
     198           1 :     std::cerr << "trg_saluInt32: " << trg_saluInt32 << std::endl;
     199             : 
     200           1 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt32 conversion to ORowSetValue didn't work", src_saluInt32 == trg_saluInt32);
     201             : 
     202           2 :     Any any_uInt32 = v.makeAny();
     203           2 :     ORowSetValue t;
     204           1 :     t.fill(any_uInt32);
     205           1 :     trg_saluInt32 = t.getUInt32();
     206             : 
     207           2 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt32 conversion from Any didn't work", src_saluInt32 == trg_saluInt32);
     208           1 : }
     209             : 
     210           1 : void FValueTest::test_Int64()
     211             : {
     212           1 :     sal_Int64 src_salInt64 = -1000000000000000001LL;
     213           1 :     ORowSetValue v(src_salInt64);
     214           1 :     sal_Int64 trg_salInt64 = v.getLong();
     215             : 
     216           1 :     std::cerr << "src_salInt64: " << src_salInt64 << std::endl;
     217           1 :     std::cerr << "trg_salInt64: " << trg_salInt64 << std::endl;
     218             : 
     219           1 :     CPPUNIT_ASSERT_MESSAGE("sal_Int64 conversion to ORowSetValue didn't work", src_salInt64 == trg_salInt64);
     220             : 
     221           2 :     Any any_Int64 = v.makeAny();
     222           2 :     ORowSetValue t;
     223           1 :     t.fill(any_Int64);
     224           1 :     trg_salInt64 = t.getLong();
     225             : 
     226           2 :     CPPUNIT_ASSERT_MESSAGE("sal_Int64 conversion from Any didn't work", src_salInt64 == trg_salInt64);
     227           1 : }
     228             : 
     229           1 : void FValueTest::test_uInt64()
     230             : {
     231           1 :     sal_uInt64 src_saluInt64 = 10000000000000000001ULL;
     232           1 :     ORowSetValue v(src_saluInt64);
     233           1 :     sal_uInt64 trg_saluInt64 = v.getULong();
     234             : 
     235           1 :     std::cerr << "src_saluInt64: " << src_saluInt64 << std::endl;
     236           1 :     std::cerr << "trg_saluInt64: " << trg_saluInt64 << std::endl;
     237             : 
     238           1 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt64 conversion to ORowSetValue didn't work", src_saluInt64 == trg_saluInt64);
     239             : 
     240           2 :     Any any_uInt64 = v.makeAny();
     241           2 :     ORowSetValue t;
     242           1 :     t.fill(any_uInt64);
     243           1 :     trg_saluInt64 = t.getULong();
     244             : 
     245           2 :     CPPUNIT_ASSERT_MESSAGE("sal_uInt64 conversion from Any didn't work", src_saluInt64 == trg_saluInt64);
     246           1 : }
     247             : 
     248           1 : void FValueTest::test_float()
     249             : {
     250           1 :     float src_float = 1.234f;
     251           1 :     ORowSetValue v(src_float);
     252           1 :     float trg_float = v.getFloat();
     253             : 
     254           1 :     std::cerr << "src_float: " << src_float << std::endl;
     255           1 :     std::cerr << "trg_float: " << trg_float << std::endl;
     256             : 
     257           1 :     CPPUNIT_ASSERT_MESSAGE("float conversion to ORowSetValue didn't work", src_float == trg_float);
     258             : 
     259           2 :     Any any_float = v.makeAny();
     260           2 :     ORowSetValue t;
     261           1 :     t.fill(any_float);
     262           1 :     trg_float = t.getFloat();
     263             : 
     264           2 :     CPPUNIT_ASSERT_MESSAGE("float conversion from Any didn't work", src_float == trg_float);
     265           1 : }
     266             : 
     267           1 : void FValueTest::test_double()
     268             : {
     269           1 :     double src_double = 1.23456789;
     270           1 :     ORowSetValue v(src_double);
     271           1 :     double trg_double = v.getDouble();
     272             : 
     273           1 :     std::cerr << "src_double: " << src_double << std::endl;
     274           1 :     std::cerr << "trg_double: " << trg_double << std::endl;
     275             : 
     276           1 :     CPPUNIT_ASSERT_MESSAGE("double conversion to ORowSetValue didn't work", src_double == trg_double);
     277             : 
     278           2 :     Any any_double = v.makeAny();
     279           2 :     ORowSetValue t;
     280           1 :     t.fill(any_double);
     281           1 :     trg_double = t.getDouble();
     282             : 
     283           2 :     CPPUNIT_ASSERT_MESSAGE("double conversion from Any didn't work", src_double == trg_double);
     284           1 : }
     285             : 
     286           1 : CPPUNIT_TEST_SUITE_REGISTRATION(FValueTest);
     287             : 
     288             : }}
     289             : 
     290           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     291             : 
     292             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10