chart2/CppunitTest_chart2_common_functors.mk | 39 ++++++++++++ chart2/Module_chart2.mk | 4 + chart2/qa/unit/common_functor_test.cxx | 85 +++++++++++++++++++++++++++ chart2/source/inc/CommonFunctors.hxx | 5 - 4 files changed, 131 insertions(+), 2 deletions(-)
New commits: commit d9e2c82470b214b45976326f6d6f411add115f77 Author: Markus Mohrhard <[email protected]> Date: Tue Sep 8 03:35:11 2015 +0200 also add test for DoubleToString Change-Id: I3de9afa7b5d975487fd03ae2a9c5393143abff9c diff --git a/chart2/qa/unit/common_functor_test.cxx b/chart2/qa/unit/common_functor_test.cxx index 272de07..ac4007c 100644 --- a/chart2/qa/unit/common_functor_test.cxx +++ b/chart2/qa/unit/common_functor_test.cxx @@ -25,9 +25,11 @@ class CommonFunctorsTest : public CppUnit::TestFixture public: CPPUNIT_TEST_SUITE(CommonFunctorsTest); CPPUNIT_TEST(testAnyToString); + CPPUNIT_TEST(testDoubleToString); CPPUNIT_TEST_SUITE_END(); void testAnyToString(); + void testDoubleToString(); private: }; @@ -54,6 +56,27 @@ void CommonFunctorsTest::testAnyToString() CPPUNIT_ASSERT_EQUAL(OUString("123.456"), aOutput[5]); } +void CommonFunctorsTest::testDoubleToString() +{ + std::vector<double> aInput; + aInput.push_back(2.0); + aInput.push_back(10.0); + aInput.push_back(12.0); + aInput.push_back(15.0); + aInput.push_back(25.234); + aInput.push_back(123.456); + + std::vector<OUString> aOutput; + std::transform(aInput.begin(), aInput.end(), + std::back_inserter(aOutput), chart::CommonFunctors::DoubleToOUString()); + + CPPUNIT_ASSERT_EQUAL(OUString("2"), aOutput[0]); + CPPUNIT_ASSERT_EQUAL(OUString("10"), aOutput[1]); + CPPUNIT_ASSERT_EQUAL(OUString("12"), aOutput[2]); + CPPUNIT_ASSERT_EQUAL(OUString("15"), aOutput[3]); + CPPUNIT_ASSERT_EQUAL(OUString("25.234"), aOutput[4]); + CPPUNIT_ASSERT_EQUAL(OUString("123.456"), aOutput[5]); +} CPPUNIT_TEST_SUITE_REGISTRATION(CommonFunctorsTest); commit bb5d638065590cba700ff46f5a0a1ffbe03b6f1a Author: Markus Mohrhard <[email protected]> Date: Tue Sep 8 03:21:21 2015 +0200 related tdf#93676, also fix chart::CommonFunctors::DoubleToOUString Change-Id: I8d63d942c7cb7876b864a9720e9a8adbc7345172 diff --git a/chart2/source/inc/CommonFunctors.hxx b/chart2/source/inc/CommonFunctors.hxx index fac5cd9..d998069 100644 --- a/chart2/source/inc/CommonFunctors.hxx +++ b/chart2/source/inc/CommonFunctors.hxx @@ -127,8 +127,9 @@ struct OOO_DLLPUBLIC_CHARTTOOLS DoubleToOUString : public ::std::unary_function< return ::rtl::math::doubleToUString( fNumber, rtl_math_StringFormat_Automatic, - -1, // use maximum number of decimal places - static_cast< sal_Char >( '.' ) + rtl_math_DecimalPlaces_Max, // use maximum decimal places available + static_cast< sal_Char >( '.' ), + true ); } }; commit f7b8bab7f38b09aff2bce9b314492677c02a3034 Author: Markus Mohrhard <[email protected]> Date: Tue Sep 8 03:18:32 2015 +0200 related tdf#93676, add test for chart::CommonFunctors Change-Id: I9667611135300155ee87cca1ad444ad8a6a9aeb1 diff --git a/chart2/CppunitTest_chart2_common_functors.mk b/chart2/CppunitTest_chart2_common_functors.mk new file mode 100644 index 0000000..fdc7f96 --- /dev/null +++ b/chart2/CppunitTest_chart2_common_functors.mk @@ -0,0 +1,39 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,chart2_common_functors)) + +$(eval $(call gb_CppunitTest_add_exception_objects,chart2_common_functors, \ + chart2/qa/unit/common_functor_test \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,chart2_common_functors, \ + cppu \ + cppuhelper \ + sal \ + salhelper \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_set_include,chart2_common_functors,\ + -I$(SRCDIR)/chart2/inc \ + -I$(SRCDIR)/chart2/source/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,chart2_common_functors,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,chart2_common_functors)) + +# vim: set noet sw=4 ts=4: diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk index de0ab12..dedb5d7 100644 --- a/chart2/Module_chart2.mk +++ b/chart2/Module_chart2.mk @@ -21,6 +21,10 @@ $(eval $(call gb_Module_add_l10n_targets,chart2,\ UIConfig_chart2 \ )) +$(eval $(call gb_Module_add_check_targets,chart2,\ + CppunitTest_chart2_common_functors \ +)) + $(eval $(call gb_Module_add_slowcheck_targets,chart2,\ CppunitTest_chart2_export \ CppunitTest_chart2_import \ diff --git a/chart2/qa/unit/common_functor_test.cxx b/chart2/qa/unit/common_functor_test.cxx new file mode 100644 index 0000000..272de07 --- /dev/null +++ b/chart2/qa/unit/common_functor_test.cxx @@ -0,0 +1,62 @@ +/* -*- 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 <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <com/sun/star/uno/Any.h> +#include <rtl/ustring.hxx> + +#include <vector> + +#include "CommonFunctors.hxx" + + +class CommonFunctorsTest : public CppUnit::TestFixture +{ +public: + CPPUNIT_TEST_SUITE(CommonFunctorsTest); + CPPUNIT_TEST(testAnyToString); + CPPUNIT_TEST_SUITE_END(); + + void testAnyToString(); + +private: +}; + +void CommonFunctorsTest::testAnyToString() +{ + std::vector<css::uno::Any> aInput; + aInput.push_back(css::uno::makeAny(2.0)); + aInput.push_back(css::uno::makeAny(10.0)); + aInput.push_back(css::uno::makeAny(12.0)); + aInput.push_back(css::uno::makeAny(15.0)); + aInput.push_back(css::uno::makeAny(25.234)); + aInput.push_back(css::uno::makeAny(123.456)); + + std::vector<OUString> aOutput; + std::transform(aInput.begin(), aInput.end(), + std::back_inserter(aOutput), chart::CommonFunctors::AnyToString()); + + CPPUNIT_ASSERT_EQUAL(OUString("2"), aOutput[0]); + CPPUNIT_ASSERT_EQUAL(OUString("10"), aOutput[1]); + CPPUNIT_ASSERT_EQUAL(OUString("12"), aOutput[2]); + CPPUNIT_ASSERT_EQUAL(OUString("15"), aOutput[3]); + CPPUNIT_ASSERT_EQUAL(OUString("25.234"), aOutput[4]); + CPPUNIT_ASSERT_EQUAL(OUString("123.456"), aOutput[5]); +} + + +CPPUNIT_TEST_SUITE_REGISTRATION(CommonFunctorsTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
