test-rtl-math.cxx (87d2adbc) | test-rtl-math.cxx (c6cdd2bd) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22 23 24#include "precompiled_sal.hxx" 25#include "sal/config.h" 26 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22 23 24#include "precompiled_sal.hxx" 25#include "sal/config.h" 26 |
27#include "cppunit/TestAssert.h" 28#include "cppunit/TestFixture.h" 29#include "cppunit/extensions/HelperMacros.h" 30#include "cppunit/plugin/TestPlugIn.h" | 27#include "gtest/gtest.h" |
31#include "rtl/math.hxx" 32#include "rtl/ustring.h" 33#include "rtl/ustring.hxx" 34#include "sal/types.h" 35 36namespace { 37 | 28#include "rtl/math.hxx" 29#include "rtl/ustring.h" 30#include "rtl/ustring.hxx" 31#include "sal/types.h" 32 33namespace { 34 |
38class Test: public CppUnit::TestFixture { 39public: 40 void test_stringToDouble_good() { 41 rtl_math_ConversionStatus status; 42 sal_Int32 end; 43 double res = rtl::math::stringToDouble( 44 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")), 45 sal_Unicode('.'), sal_Unicode(','), &status, &end); 46 CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); 47 CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end); 48 CPPUNIT_ASSERT_EQUAL(10.0, res); 49 } 50 51 void test_stringToDouble_bad() { 52 rtl_math_ConversionStatus status; 53 sal_Int32 end; 54 double res = rtl::math::stringToDouble( 55 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")), 56 sal_Unicode('.'), sal_Unicode(','), &status, &end); 57 CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); 58 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); 59 CPPUNIT_ASSERT_EQUAL(0.0, res); 60 } 61 62 CPPUNIT_TEST_SUITE(Test); 63 CPPUNIT_TEST(test_stringToDouble_good); 64 CPPUNIT_TEST(test_stringToDouble_bad); 65 CPPUNIT_TEST_SUITE_END(); | 35class Test: public ::testing::Test { |
66}; 67 | 36}; 37 |
68CPPUNIT_TEST_SUITE_REGISTRATION(Test); | 38TEST_F(Test, test_stringToDouble_good) { 39 rtl_math_ConversionStatus status; 40 sal_Int32 end; 41 double res = rtl::math::stringToDouble( 42 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")), 43 sal_Unicode('.'), sal_Unicode(','), &status, &end); 44 ASSERT_EQ(rtl_math_ConversionStatus_Ok, status); 45 ASSERT_EQ(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end); 46 ASSERT_EQ(10.0, res); 47} |
69 | 48 |
49TEST_F(Test, test_stringToDouble_bad) { 50 rtl_math_ConversionStatus status; 51 sal_Int32 end; 52 double res = rtl::math::stringToDouble( 53 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")), 54 sal_Unicode('.'), sal_Unicode(','), &status, &end); 55 ASSERT_EQ(rtl_math_ConversionStatus_Ok, status); 56 ASSERT_EQ(sal_Int32(0), end); 57 ASSERT_EQ(0.0, res); |
|
70} 71 | 58} 59 |
72CPPUNIT_PLUGIN_IMPLEMENT(); | 60} 61 62int main(int argc, char **argv) 63{ 64 ::testing::InitGoogleTest(&argc, argv); 65 return RUN_ALL_TESTS(); 66} |