[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 2 commits - slideshow/test tools/GoogleTest_tools_fractiontest.mk tools/Module_tools.mk tools/test
Damjan Jovanovic
damjan at apache.org
Fri Sep 18 13:07:58 PDT 2015
slideshow/test/demoshow.cxx | 16 +++-
tools/GoogleTest_tools_fractiontest.mk | 48 ++++++++++++
tools/Module_tools.mk | 6 +
tools/test/tests.cxx | 124 ++++++++++++++-------------------
4 files changed, 121 insertions(+), 73 deletions(-)
New commits:
commit 4fd1da68f70f61290ebd1fc47e27f75b5827872a
Author: Damjan Jovanovic <damjan at apache.org>
Date: Fri Sep 18 05:26:04 2015 +0000
Get main/slideshow/test/demoshow compiling on Windows.
diff --git a/slideshow/test/demoshow.cxx b/slideshow/test/demoshow.cxx
index 8defb4f..ea9dccb 100644
--- a/slideshow/test/demoshow.cxx
+++ b/slideshow/test/demoshow.cxx
@@ -19,11 +19,13 @@
*
*************************************************************/
-
+#include "precompiled_slideshow.hxx"
#include <sal/main.h>
#include <rtl/ref.hxx>
#include <rtl/bootstrap.hxx>
+#include <osl/process.h>
+#include <tools/extendapplicationenvironment.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/servicefactory.hxx>
@@ -575,4 +577,14 @@ void DemoApp::Main()
}
}
-DemoApp aApp;
+sal_Bool SVMain();
+
+int main(int argc, char **argv)
+{
+ tools::extendApplicationEnvironment();
+
+ DemoApp aApp;
+ SVMain();
+
+ return 0;
+}
commit 2405932fc01436658ff57d8eb7b1f706913495ce
Author: Damjan Jovanovic <damjan at apache.org>
Date: Thu Sep 17 21:28:13 2015 +0000
#i125003# Migrate main/tools/tests from cppunit to Google Test.
diff --git a/tools/GoogleTest_tools_fractiontest.mk b/tools/GoogleTest_tools_fractiontest.mk
new file mode 100644
index 0000000..f5eefef
--- /dev/null
+++ b/tools/GoogleTest_tools_fractiontest.mk
@@ -0,0 +1,48 @@
+#**************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#**************************************************************
+
+
+$(eval $(call gb_GoogleTest_GoogleTest,tools_fractiontest))
+
+$(eval $(call gb_GoogleTest_add_exception_objects,tools_fractiontest, \
+ tools/test/tests \
+))
+
+$(eval $(call gb_GoogleTest_add_linked_libs,tools_fractiontest, \
+ tl \
+ sal \
+ sfx \
+ stl \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_GoogleTest_set_include,tools_fractiontest,\
+ $$(INCLUDE) \
+ -I$(OUTDIR)/inc/offuh \
+ -I$(OUTDIR)/inc \
+ -I$(SRCDIR)/tools/inc/pch \
+))
+
+$(eval $(call gb_GoogleTest_set_ldflags,tools_fractiontest,\
+ $$(LDFLAGS) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/tools/Module_tools.mk b/tools/Module_tools.mk
index e46f0a9..53a9841 100644
--- a/tools/Module_tools.mk
+++ b/tools/Module_tools.mk
@@ -34,4 +34,10 @@ $(eval $(call gb_Module_add_targets,tools,\
StaticLibrary_ooopathutils \
))
+ifeq ($(ENABLE_UNIT_TESTS),YES)
+$(eval $(call gb_Module_add_check_targets,tools,\
+ GoogleTest_tools_fractiontest \
+))
+endif
+
# vim: set noet sw=4 ts=4:
diff --git a/tools/test/tests.cxx b/tools/test/tests.cxx
index 0e715f5..a3501fd 100644
--- a/tools/test/tests.cxx
+++ b/tools/test/tests.cxx
@@ -24,7 +24,7 @@
#include "precompiled_tools.hxx"
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
#include <rtl/math.hxx>
#include <tools/fract.hxx>
@@ -33,88 +33,70 @@
namespace tools
{
-class FractionTest : public CppUnit::TestFixture
+class FractionTest : public ::testing::Test
{
public:
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+};
- void testFraction()
- {
- const Fraction aFract(1082130431,1073741824);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #1 not approximately equal to 1.007812499068677",
- rtl::math::approxEqual((double)aFract,1.007812499068677) );
-
- Fraction aFract2( aFract );
- aFract2.ReduceInaccurate(8);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #2 not 1",
- aFract2.GetNumerator() == 1 &&
- aFract2.GetDenominator() == 1 );
-
- Fraction aFract3( 0x7AAAAAAA, 0x35555555 );
- CPPUNIT_ASSERT_MESSAGE( "Fraction #3 cancellation wrong",
- aFract3.GetNumerator() == 0x7AAAAAAA &&
- aFract3.GetDenominator() == 0x35555555 );
- aFract3.ReduceInaccurate(30);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #3 ReduceInaccurate errorneously cut precision",
- aFract3.GetNumerator() == 0x7AAAAAAA &&
- aFract3.GetDenominator() == 0x35555555 );
-
- aFract3.ReduceInaccurate(29);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #3 reduce to 29 bits failed",
- aFract3.GetNumerator() == 0x3D555555 &&
- aFract3.GetDenominator() == 0x1AAAAAAA );
-
- aFract3.ReduceInaccurate(9);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #3 reduce to 9 bits failed",
- aFract3.GetNumerator() == 0x0147 &&
- aFract3.GetDenominator() == 0x008E );
-
- aFract3.ReduceInaccurate(1);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #3 reduce to 1 bit failed",
- aFract3.GetNumerator() == 2 &&
- aFract3.GetDenominator() == 1 );
-
- aFract3.ReduceInaccurate(0);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #3 reduce to 0 bits failed",
- aFract3.GetNumerator() == 2 &&
- aFract3.GetDenominator() == 1 );
+TEST_F(FractionTest, testFraction)
+{
+ const Fraction aFract(1082130431,1073741824);
+ ASSERT_TRUE(rtl::math::approxEqual((double)aFract,1.007812499068677)) << "Fraction #1 not approximately equal to 1.007812499068677";
-#if SAL_TYPES_SIZEOFLONG == 8
- Fraction aFract4(0x7AAAAAAAAAAAAAAA, 0x3555555555555555);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #4 cancellation wrong",
- aFract4.GetNumerator() == 0x7AAAAAAAAAAAAAAA &&
- aFract4.GetDenominator() == 0x3555555555555555 );
- aFract4.ReduceInaccurate(62);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #4 ReduceInaccurate errorneously cut precision",
- aFract4.GetNumerator() == 0x7AAAAAAAAAAAAAAA &&
- aFract4.GetDenominator() == 0x3555555555555555 );
-
- aFract4.ReduceInaccurate(61);
- CPPUNIT_ASSERT_MESSAGE( "Fraction #4 ReduceInaccurate reduce to 61 bit failed",
- aFract4.GetNumerator() == 0x3D55555555555555 &&
- aFract4.GetDenominator() == 0x1AAAAAAAAAAAAAAA );
-#endif
- }
+ Fraction aFract2( aFract );
+ aFract2.ReduceInaccurate(8);
+ ASSERT_TRUE(aFract2.GetNumerator() == 1 &&
+ aFract2.GetDenominator() == 1) << "Fraction #2 not 1";
- CPPUNIT_TEST_SUITE(FractionTest);
- CPPUNIT_TEST(testFraction);
- CPPUNIT_TEST_SUITE_END();
-};
+ Fraction aFract3( 0x7AAAAAAA, 0x35555555 );
+ ASSERT_TRUE(aFract3.GetNumerator() == 0x7AAAAAAA &&
+ aFract3.GetDenominator() == 0x35555555) << "Fraction #3 cancellation wrong";
+ aFract3.ReduceInaccurate(30);
+ ASSERT_TRUE(aFract3.GetNumerator() == 0x7AAAAAAA &&
+ aFract3.GetDenominator() == 0x35555555) << "Fraction #3 ReduceInaccurate errorneously cut precision";
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(tools::FractionTest, "FractionTest");
-} // namespace tools
+ aFract3.ReduceInaccurate(29);
+ ASSERT_TRUE(aFract3.GetNumerator() == 0x3D555555 &&
+ aFract3.GetDenominator() == 0x1AAAAAAA) << "Fraction #3 reduce to 29 bits failed";
+ aFract3.ReduceInaccurate(9);
+ ASSERT_TRUE(aFract3.GetNumerator() == 0x0147 &&
+ aFract3.GetDenominator() == 0x008E) << "Fraction #3 reduce to 9 bits failed";
-// -----------------------------------------------------------------------------
+ aFract3.ReduceInaccurate(1);
+ ASSERT_TRUE(aFract3.GetNumerator() == 2 &&
+ aFract3.GetDenominator() == 1) << "Fraction #3 reduce to 1 bit failed";
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
+ aFract3.ReduceInaccurate(0);
+ ASSERT_TRUE(aFract3.GetNumerator() == 2 &&
+ aFract3.GetDenominator() == 1) << "Fraction #3 reduce to 0 bits failed";
+#if SAL_TYPES_SIZEOFLONG == 8
+ Fraction aFract4(0x7AAAAAAAAAAAAAAA, 0x3555555555555555);
+ ASSERT_TRUE(aFract4.GetNumerator() == 0x7AAAAAAAAAAAAAAA &&
+ aFract4.GetDenominator() == 0x3555555555555555) << "Fraction #4 cancellation wrong";
+ aFract4.ReduceInaccurate(62);
+ ASSERT_TRUE(aFract4.GetNumerator() == 0x7AAAAAAAAAAAAAAA &&
+ aFract4.GetDenominator() == 0x3555555555555555) << "Fraction #4 ReduceInaccurate errorneously cut precision";
+
+ aFract4.ReduceInaccurate(61);
+ ASSERT_TRUE(aFract4.GetNumerator() == 0x3D55555555555555 &&
+ aFract4.GetDenominator() == 0x1AAAAAAAAAAAAAAA) << "Fraction #4 ReduceInaccurate reduce to 61 bit failed";
+#endif
+}
+
+} // namespace tools
+
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
More information about the Libreoffice-commits
mailing list