Kaydet (Commit) 92c4e2f2 authored tarafından Damjan Jovanovic's avatar Damjan Jovanovic

#i125003# migrate main/sal/qa/rtl/math from cppunit to Google Test.

üst 802a2d56
......@@ -33,19 +33,21 @@ ENABLE_EXCEPTIONS = TRUE
.INCLUDE: settings.mk
CFLAGSCXX += $(CPPUNIT_CFLAGS)
.IF "$(ENABLE_UNIT_TESTS)" != "YES"
all:
@echo unit tests are disabled. Nothing to do.
.ELSE
SHL1IMPLIB = i$(SHL1TARGET)
SHL1OBJS = $(SLO)/test-rtl-math.obj
SHL1RPATH = NONE
SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB)
SHL1TARGET = test-rtl-math
SHL1VERSIONMAP = $(PRJ)/qa/export.map
DEF1NAME = $(SHL1TARGET)
SLOFILES = $(SHL1OBJS)
APP1OBJS = $(SLO)/test-rtl-math.obj
APP1RPATH = NONE
APP1STDLIBS = $(GTESTLIB) $(SALLIB)
APP1TARGET = test-rtl-math
APP1TEST = enabled
.INCLUDE: target.mk
.INCLUDE: _cppunit.mk
.END
.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
.END # "$(OOO_SUBSEQUENT_TESTS)" == ""
......@@ -24,10 +24,7 @@
#include "precompiled_sal.hxx"
#include "sal/config.h"
#include "cppunit/TestAssert.h"
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
#include "gtest/gtest.h"
#include "rtl/math.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
......@@ -35,38 +32,35 @@
namespace {
class Test: public CppUnit::TestFixture {
public:
void test_stringToDouble_good() {
rtl_math_ConversionStatus status;
sal_Int32 end;
double res = rtl::math::stringToDouble(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")),
sal_Unicode('.'), sal_Unicode(','), &status, &end);
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end);
CPPUNIT_ASSERT_EQUAL(10.0, res);
}
void test_stringToDouble_bad() {
rtl_math_ConversionStatus status;
sal_Int32 end;
double res = rtl::math::stringToDouble(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")),
sal_Unicode('.'), sal_Unicode(','), &status, &end);
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end);
CPPUNIT_ASSERT_EQUAL(0.0, res);
}
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(test_stringToDouble_good);
CPPUNIT_TEST(test_stringToDouble_bad);
CPPUNIT_TEST_SUITE_END();
class Test: public ::testing::Test {
};
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
TEST_F(Test, test_stringToDouble_good) {
rtl_math_ConversionStatus status;
sal_Int32 end;
double res = rtl::math::stringToDouble(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")),
sal_Unicode('.'), sal_Unicode(','), &status, &end);
ASSERT_EQ(rtl_math_ConversionStatus_Ok, status);
ASSERT_EQ(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end);
ASSERT_EQ(10.0, res);
}
TEST_F(Test, test_stringToDouble_bad) {
rtl_math_ConversionStatus status;
sal_Int32 end;
double res = rtl::math::stringToDouble(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")),
sal_Unicode('.'), sal_Unicode(','), &status, &end);
ASSERT_EQ(rtl_math_ConversionStatus_Ok, status);
ASSERT_EQ(sal_Int32(0), end);
ASSERT_EQ(0.0, res);
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment