LCOV - code coverage report
Current view: top level - test/source/sheet - xcellrangesquery.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 49 57 86.0 %
Date: 2014-11-03 Functions: 8 9 88.9 %
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             : 
      10             : #include <test/sheet/xcellrangesquery.hxx>
      11             : 
      12             : #include <com/sun/star/sheet/XCellRangesQuery.hpp>
      13             : #include <com/sun/star/sheet/XSheetCellRanges.hpp>
      14             : #include <com/sun/star/table/CellAddress.hpp>
      15             : #include <com/sun/star/sheet/CellFlags.hpp>
      16             : 
      17             : #include "cppunit/extensions/HelperMacros.h"
      18             : 
      19             : using namespace com::sun::star;
      20             : using namespace com::sun::star::uno;
      21             : 
      22             : 
      23             : namespace apitest {
      24             : 
      25           2 : void XCellRangesQuery::testQueryColumnDifference()
      26             : {
      27           2 :     OUString aExpected( "Sheet1.B1:C1,Sheet1.B3:C5" );
      28           4 :     uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
      29           4 :     uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
      30           4 :     OUString aResult = xRanges->getRangeAddressesAsString();
      31           2 :     std::cout << "testQueryColumnDifference: Result: " << OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
      32           4 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", aResult, aExpected);
      33           2 : }
      34             : 
      35           2 : void XCellRangesQuery::testQueryContentDifference()
      36             : {
      37           2 :     OUString aExpected( "Sheet1.B2:B3" );
      38           4 :     uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
      39           4 :     uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
      40           4 :     OUString aResult = xRanges->getRangeAddressesAsString();
      41           2 :     std::cout << "testQueryContentDifference: Result: " << OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
      42           4 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", aResult, aExpected);
      43           2 : }
      44             : 
      45           2 : void XCellRangesQuery::testQueryEmptyCells()
      46             : {
      47           2 :     OUString aExpected( "Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:D5" );
      48           4 :     uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
      49           4 :     uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
      50           4 :     OUString aResult = xRanges->getRangeAddressesAsString();
      51           2 :     std::cout << "testQueryEmptyCells: Result: " << OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
      52           4 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", aResult, aExpected);
      53           2 : }
      54             : 
      55           0 : void XCellRangesQuery::testQueryFormulaCells()
      56             : {
      57           0 :     OUString aExpected( "Sheet1.C2" );
      58           0 :     uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
      59           0 :     uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
      60           0 :     OUString aResult = xRanges->getRangeAddressesAsString();
      61           0 :     std::cout << "testQueryFormulaCells: Result: " << OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
      62           0 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", aResult, aExpected);
      63           0 : }
      64             : 
      65           2 : void XCellRangesQuery::testQueryIntersection()
      66             : {
      67           2 :     OUString aExpected( "Sheet1.D4:D5" );
      68           4 :     uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
      69           4 :     uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
      70           4 :     OUString aResult = xRanges->getRangeAddressesAsString();
      71           2 :     std::cout << "testQueryIntersection: Result: " << OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
      72           4 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", aResult, aExpected);
      73           2 : }
      74             : 
      75           2 : void XCellRangesQuery::testQueryRowDifference()
      76             : {
      77           2 :     OUString aExpected( "Sheet1.A2:A4,Sheet1.C2:D4" );
      78           4 :     uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
      79           4 :     uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
      80           4 :     OUString aResult = xRanges->getRangeAddressesAsString();
      81           2 :     std::cout << "testQueryRowDifference: Result: " << OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
      82           4 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", aResult, aExpected);
      83           2 : }
      84             : 
      85           2 : void XCellRangesQuery::testQueryVisibleCells()
      86             : {
      87           2 :     OUString aExpected( "Sheet1.A1:D5" );
      88           4 :     uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
      89           4 :     uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
      90           4 :     OUString aResult = xRanges->getRangeAddressesAsString();
      91           2 :     std::cout << "testQueryVisibleCells: Result: " << OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
      92           4 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", aResult, aExpected);
      93           2 : }
      94             : 
      95         144 : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10