|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73466 - in sandbox/e_float: boost/e_float libs/e_float/src/e_float libs/e_float/test/real libs/e_float/test/real/cases
From: e_float_at_[hidden]
Date: 2011-07-31 11:44:49
Author: christopher_kormanyos
Date: 2011-07-31 11:44:48 EDT (Sun, 31 Jul 2011)
New Revision: 73466
URL: http://svn.boost.org/trac/boost/changeset/73466
Log:
- Added additional ostream write function tests.
- Cleaned up the Lib/DLL digit check mechanism.
Text files modified:
sandbox/e_float/boost/e_float/e_float_base.hpp | 19 +++--
sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp | 3
sandbox/e_float/libs/e_float/test/real/cases/test_case_0000y_write_to_ostream.cpp | 88 +++++++++++++++++++++++
sandbox/e_float/libs/e_float/test/real/test_real.cpp | 146 ++++++++++++++++++++-------------------
4 files changed, 174 insertions(+), 82 deletions(-)
Modified: sandbox/e_float/boost/e_float/e_float_base.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_base.hpp (original)
+++ sandbox/e_float/boost/e_float/e_float_base.hpp 2011-07-31 11:44:48 EDT (Sun, 31 Jul 2011)
@@ -43,10 +43,6 @@
#error The e_float type is undefined! Define the e_float type!
#endif
- // Create a loud link error if the e_float headers mismatch a Lib or DLL.
- template<const INT32 digits10> INT32 digits_match_lib_dll(void);
- template<> INT32 digits_match_lib_dll<E_FLOAT_DIGITS10>(void);
-
class e_float_base
{
public:
@@ -163,15 +159,22 @@
static e_float my_cyl_bessel_yn(const INT32, const e_float&);
protected:
- e_float_base()
- {
- digits_match_lib_dll_is_ok = (::digits_match_lib_dll<E_FLOAT_DIGITS10>() == E_FLOAT_DIGITS10);
- }
+ inline e_float_base();
private:
static bool digits_match_lib_dll_is_ok;
};
+ // Create a loud link error if the digits in the
+ // e_float headers mismatch those in a Lib or DLL.
+ template<const INT32 digits10> INT32 digits_match_lib_dll(void); // There's no function body here.
+ template<> INT32 digits_match_lib_dll<e_float_base::ef_digits10>(void); // The function body is in e_float_base.cpp.
+
+ inline e_float_base::e_float_base()
+ {
+ digits_match_lib_dll_is_ok = (::digits_match_lib_dll<ef_digits10>() == ef_digits10);
+ }
+
std::ostream& operator<<(std::ostream& os, const e_float_base& f);
std::istream& operator>>(std::istream& is, e_float_base& f);
Modified: sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp (original)
+++ sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp 2011-07-31 11:44:48 EDT (Sun, 31 Jul 2011)
@@ -13,7 +13,8 @@
bool e_float_base::digits_match_lib_dll_is_ok;
-// Create a loud link error if the e_float headers mismatch a Lib or DLL.
+// Create a loud link error if the digits in the
+// e_float headers mismatch those in a Lib or DLL.
template<> INT32 digits_match_lib_dll<e_float_base::ef_digits10>(void) { return e_float_base::ef_digits10; }
std::ostream& operator<<(std::ostream& os, const e_float_base& f)
Modified: sandbox/e_float/libs/e_float/test/real/cases/test_case_0000y_write_to_ostream.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/test/real/cases/test_case_0000y_write_to_ostream.cpp (original)
+++ sandbox/e_float/libs/e_float/test/real/cases/test_case_0000y_write_to_ostream.cpp 2011-07-31 11:44:48 EDT (Sun, 31 Jul 2011)
@@ -188,7 +188,8 @@
str = ss.str();
data.push_back(e_float(str));
str_pi = ::make_pi_string(static_cast<std::size_t>(std::numeric_limits<e_float>::max_digits10));
- my_test_result &= (str == (std::string("+") + (str_pi + std::string(1002u - str_pi.length(), static_cast<char>('0')))));
+ const std::string str_zero_fill(1002u - str_pi.length(), static_cast<char>('0'));
+ my_test_result &= (str == (std::string("+") + (str_pi + str_zero_fill)));
ss.clear();
ss.str("");
@@ -213,9 +214,94 @@
}
};
+ class TestCase_case_00007_write_os_floatfield_scientific : public TestCaseWriteToOstreamBase
+ {
+ public:
+ TestCase_case_00007_write_os_floatfield_scientific() { }
+ virtual ~TestCase_case_00007_write_os_floatfield_scientific() { }
+ private:
+ virtual const std::string& name(void) const
+ {
+ static const std::string str("TestCase_case_00007_write_os_floatfield_scientific");
+ return str;
+ }
+ virtual void e_float_test(std::vector<e_float>& data) const
+ {
+ data.clear();
+
+ my_test_result = true;
+
+ std::string str;
+ std::stringstream ss;
+
+ ss << std::scientific << std::showpos << std::showpoint << std::setprecision(1) << ef::pi();
+ str = ss.str();
+ data.push_back(e_float(str));
+ my_test_result &= (str == std::string("+3.1e+000"));
+ ss.clear();
+ ss.str("");
+
+ ss << std::scientific << std::showpos << std::showpoint << std::setprecision(2) << ef::pi();
+ str = ss.str();
+ data.push_back(e_float(str));
+ my_test_result &= (str == std::string("+3.14e+000"));
+ ss.clear();
+ ss.str("");
+
+ ss << std::scientific << std::showpos << std::showpoint << std::setprecision(20) << ef::pi();
+ str = ss.str();
+ data.push_back(e_float(str));
+ my_test_result &= (str == std::string("+3.14159265358979323846e+000"));
+ ss.clear();
+ ss.str("");
+
+ ss << std::scientific << std::showpos << std::showpoint << std::setprecision(std::numeric_limits<e_float>::digits10) << ef::pi();
+ str = ss.str();
+ data.push_back(e_float(str));
+ std::string str_pi = ::make_pi_string(static_cast<std::size_t>(std::numeric_limits<e_float>::digits10));
+ my_test_result &= (str == (std::string("+") + (str_pi + std::string("e+000"))));
+ ss.clear();
+ ss.str("");
+
+ ss << std::scientific << std::showpos << std::showpoint << std::setprecision(1000) << ef::pi();
+ str = ss.str();
+ data.push_back(e_float(str));
+ str_pi = ::make_pi_string(static_cast<std::size_t>(std::numeric_limits<e_float>::max_digits10));
+ const std::string str_zero_fill(1002u - str_pi.length(), static_cast<char>('0'));
+ my_test_result &= (str == (std::string("+") + ((str_pi + str_zero_fill) + std::string("e+000"))));
+ ss.clear();
+ ss.str("");
+
+ ss << std::scientific << std::showpos << std::showpoint << std::setprecision(20) << ef::pi() * e_float("1e43");
+ str = ss.str();
+ data.push_back(e_float(str));
+ my_test_result &= (str == std::string("+3.14159265358979323846e+043"));
+ ss.clear();
+ ss.str("");
+
+ ss << std::scientific << std::showpos << std::showpoint << std::setprecision(20) << -ef::pi() * e_float("1e-43");
+ str = ss.str();
+ data.push_back(e_float(str));
+ my_test_result &= (str == std::string("-3.14159265358979323846e-043"));
+ ss.clear();
+ ss.str("");
+
+ ss << std::scientific << std::showpos << std::showpoint << std::uppercase << std::setprecision(20) << ef::pi();
+ str = ss.str();
+ data.push_back(e_float(str));
+ my_test_result &= (str == std::string("+3.14159265358979323846E+000"));
+ ss.clear();
+ ss.str("");
+ }
+ };
+
bool test_case_00006_write_os_floatfield_fixed(const bool b_write_output)
{
return TestCase_case_00006_write_os_floatfield_fixed().execute(b_write_output);
}
+ bool test_case_00007_write_os_floatfield_scientific(const bool b_write_output)
+ {
+ return TestCase_case_00007_write_os_floatfield_scientific().execute(b_write_output);
+ }
}
}
Modified: sandbox/e_float/libs/e_float/test/real/test_real.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/test/real/test_real.cpp (original)
+++ sandbox/e_float/libs/e_float/test/real/test_real.cpp 2011-07-31 11:44:48 EDT (Sun, 31 Jul 2011)
@@ -16,42 +16,43 @@
{
namespace real
{
- bool test_case_00001_overflow_mul_x (const bool b_write_output);
- bool test_case_00002_underflow_mul_x (const bool b_write_output);
- bool test_case_00003_overflow_x_mul_by_n (const bool b_write_output);
- bool test_case_00004_underflow_x_div_by_n (const bool b_write_output);
- bool test_case_00006_write_os_floatfield_fixed(const bool b_write_output);
- bool test_case_00011_various_elem_math (const bool b_write_output);
- bool test_case_00021_bernoulli (const bool b_write_output);
- bool test_case_00051_factorial (const bool b_write_output);
- bool test_case_00052_factorial2 (const bool b_write_output);
- bool test_case_00071_various_int_func (const bool b_write_output);
- bool test_case_00101_sin (const bool b_write_output);
- bool test_case_00102_cos (const bool b_write_output);
- bool test_case_00103_exp (const bool b_write_output);
- bool test_case_00104_log (const bool b_write_output);
- bool test_case_00105_sqrt (const bool b_write_output);
- bool test_case_00106_rootn (const bool b_write_output);
- bool test_case_00111_sin_small_x (const bool b_write_output);
- bool test_case_00112_cos_x_near_pi_half (const bool b_write_output);
- bool test_case_00113_atan_x_small_to_large (const bool b_write_output);
- bool test_case_00114_various_trig (const bool b_write_output);
- bool test_case_00115_various_elem_trans (const bool b_write_output);
- bool test_case_00121_sinh (const bool b_write_output);
- bool test_case_00122_cosh (const bool b_write_output);
- bool test_case_00123_tanh (const bool b_write_output);
- bool test_case_00124_asinh (const bool b_write_output);
- bool test_case_00125_acosh (const bool b_write_output);
- bool test_case_00126_atanh (const bool b_write_output);
- bool test_case_00201_gamma (const bool b_write_output);
- bool test_case_00202_gamma_medium_x (const bool b_write_output);
- bool test_case_00203_gamma_small_x (const bool b_write_output);
- bool test_case_00204_gamma_tiny_x (const bool b_write_output);
- bool test_case_00205_gamma_near_neg_n (const bool b_write_output);
- bool test_case_00221_various_gamma_func (const bool b_write_output);
- bool test_case_00901_zeta_small_x (const bool b_write_output);
- bool test_case_00902_zeta_all_x (const bool b_write_output);
- bool test_case_00903_zeta_neg_x (const bool b_write_output);
+ bool test_case_00001_overflow_mul_x (const bool b_write_output);
+ bool test_case_00002_underflow_mul_x (const bool b_write_output);
+ bool test_case_00003_overflow_x_mul_by_n (const bool b_write_output);
+ bool test_case_00004_underflow_x_div_by_n (const bool b_write_output);
+ bool test_case_00006_write_os_floatfield_fixed (const bool b_write_output);
+ bool test_case_00007_write_os_floatfield_scientific(const bool b_write_output);
+ bool test_case_00011_various_elem_math (const bool b_write_output);
+ bool test_case_00021_bernoulli (const bool b_write_output);
+ bool test_case_00051_factorial (const bool b_write_output);
+ bool test_case_00052_factorial2 (const bool b_write_output);
+ bool test_case_00071_various_int_func (const bool b_write_output);
+ bool test_case_00101_sin (const bool b_write_output);
+ bool test_case_00102_cos (const bool b_write_output);
+ bool test_case_00103_exp (const bool b_write_output);
+ bool test_case_00104_log (const bool b_write_output);
+ bool test_case_00105_sqrt (const bool b_write_output);
+ bool test_case_00106_rootn (const bool b_write_output);
+ bool test_case_00111_sin_small_x (const bool b_write_output);
+ bool test_case_00112_cos_x_near_pi_half (const bool b_write_output);
+ bool test_case_00113_atan_x_small_to_large (const bool b_write_output);
+ bool test_case_00114_various_trig (const bool b_write_output);
+ bool test_case_00115_various_elem_trans (const bool b_write_output);
+ bool test_case_00121_sinh (const bool b_write_output);
+ bool test_case_00122_cosh (const bool b_write_output);
+ bool test_case_00123_tanh (const bool b_write_output);
+ bool test_case_00124_asinh (const bool b_write_output);
+ bool test_case_00125_acosh (const bool b_write_output);
+ bool test_case_00126_atanh (const bool b_write_output);
+ bool test_case_00201_gamma (const bool b_write_output);
+ bool test_case_00202_gamma_medium_x (const bool b_write_output);
+ bool test_case_00203_gamma_small_x (const bool b_write_output);
+ bool test_case_00204_gamma_tiny_x (const bool b_write_output);
+ bool test_case_00205_gamma_near_neg_n (const bool b_write_output);
+ bool test_case_00221_various_gamma_func (const bool b_write_output);
+ bool test_case_00901_zeta_small_x (const bool b_write_output);
+ bool test_case_00902_zeta_all_x (const bool b_write_output);
+ bool test_case_00903_zeta_neg_x (const bool b_write_output);
}
}
@@ -59,42 +60,43 @@
{
bool test_ok = true;
- test_ok &= test::real::test_case_00001_overflow_mul_x (b_write_output);
- test_ok &= test::real::test_case_00002_underflow_mul_x (b_write_output);
- test_ok &= test::real::test_case_00003_overflow_x_mul_by_n (b_write_output);
- test_ok &= test::real::test_case_00004_underflow_x_div_by_n (b_write_output);
- test_ok &= test::real::test_case_00006_write_os_floatfield_fixed(b_write_output);
- test_ok &= test::real::test_case_00011_various_elem_math (b_write_output);
- test_ok &= test::real::test_case_00021_bernoulli (b_write_output);
- test_ok &= test::real::test_case_00051_factorial (b_write_output);
- test_ok &= test::real::test_case_00052_factorial2 (b_write_output);
- test_ok &= test::real::test_case_00071_various_int_func (b_write_output);
- test_ok &= test::real::test_case_00101_sin (b_write_output);
- test_ok &= test::real::test_case_00102_cos (b_write_output);
- test_ok &= test::real::test_case_00103_exp (b_write_output);
- test_ok &= test::real::test_case_00104_log (b_write_output);
- test_ok &= test::real::test_case_00105_sqrt (b_write_output);
- test_ok &= test::real::test_case_00106_rootn (b_write_output);
- test_ok &= test::real::test_case_00111_sin_small_x (b_write_output);
- test_ok &= test::real::test_case_00112_cos_x_near_pi_half (b_write_output);
- test_ok &= test::real::test_case_00113_atan_x_small_to_large (b_write_output);
- test_ok &= test::real::test_case_00114_various_trig (b_write_output);
- test_ok &= test::real::test_case_00115_various_elem_trans (b_write_output);
- test_ok &= test::real::test_case_00121_sinh (b_write_output);
- test_ok &= test::real::test_case_00122_cosh (b_write_output);
- test_ok &= test::real::test_case_00123_tanh (b_write_output);
- test_ok &= test::real::test_case_00124_asinh (b_write_output);
- test_ok &= test::real::test_case_00125_acosh (b_write_output);
- test_ok &= test::real::test_case_00126_atanh (b_write_output);
- test_ok &= test::real::test_case_00201_gamma (b_write_output);
- test_ok &= test::real::test_case_00202_gamma_medium_x (b_write_output);
- test_ok &= test::real::test_case_00203_gamma_small_x (b_write_output);
- test_ok &= test::real::test_case_00204_gamma_tiny_x (b_write_output);
- test_ok &= test::real::test_case_00205_gamma_near_neg_n (b_write_output);
- test_ok &= test::real::test_case_00221_various_gamma_func (b_write_output);
- test_ok &= test::real::test_case_00901_zeta_small_x (b_write_output);
- test_ok &= test::real::test_case_00902_zeta_all_x (b_write_output);
- test_ok &= test::real::test_case_00903_zeta_neg_x (b_write_output);
+ test_ok &= test::real::test_case_00001_overflow_mul_x (b_write_output);
+ test_ok &= test::real::test_case_00002_underflow_mul_x (b_write_output);
+ test_ok &= test::real::test_case_00003_overflow_x_mul_by_n (b_write_output);
+ test_ok &= test::real::test_case_00004_underflow_x_div_by_n (b_write_output);
+ test_ok &= test::real::test_case_00006_write_os_floatfield_fixed (b_write_output);
+ test_ok &= test::real::test_case_00007_write_os_floatfield_scientific(b_write_output);
+ test_ok &= test::real::test_case_00011_various_elem_math (b_write_output);
+ test_ok &= test::real::test_case_00021_bernoulli (b_write_output);
+ test_ok &= test::real::test_case_00051_factorial (b_write_output);
+ test_ok &= test::real::test_case_00052_factorial2 (b_write_output);
+ test_ok &= test::real::test_case_00071_various_int_func (b_write_output);
+ test_ok &= test::real::test_case_00101_sin (b_write_output);
+ test_ok &= test::real::test_case_00102_cos (b_write_output);
+ test_ok &= test::real::test_case_00103_exp (b_write_output);
+ test_ok &= test::real::test_case_00104_log (b_write_output);
+ test_ok &= test::real::test_case_00105_sqrt (b_write_output);
+ test_ok &= test::real::test_case_00106_rootn (b_write_output);
+ test_ok &= test::real::test_case_00111_sin_small_x (b_write_output);
+ test_ok &= test::real::test_case_00112_cos_x_near_pi_half (b_write_output);
+ test_ok &= test::real::test_case_00113_atan_x_small_to_large (b_write_output);
+ test_ok &= test::real::test_case_00114_various_trig (b_write_output);
+ test_ok &= test::real::test_case_00115_various_elem_trans (b_write_output);
+ test_ok &= test::real::test_case_00121_sinh (b_write_output);
+ test_ok &= test::real::test_case_00122_cosh (b_write_output);
+ test_ok &= test::real::test_case_00123_tanh (b_write_output);
+ test_ok &= test::real::test_case_00124_asinh (b_write_output);
+ test_ok &= test::real::test_case_00125_acosh (b_write_output);
+ test_ok &= test::real::test_case_00126_atanh (b_write_output);
+ test_ok &= test::real::test_case_00201_gamma (b_write_output);
+ test_ok &= test::real::test_case_00202_gamma_medium_x (b_write_output);
+ test_ok &= test::real::test_case_00203_gamma_small_x (b_write_output);
+ test_ok &= test::real::test_case_00204_gamma_tiny_x (b_write_output);
+ test_ok &= test::real::test_case_00205_gamma_near_neg_n (b_write_output);
+ test_ok &= test::real::test_case_00221_various_gamma_func (b_write_output);
+ test_ok &= test::real::test_case_00901_zeta_small_x (b_write_output);
+ test_ok &= test::real::test_case_00902_zeta_all_x (b_write_output);
+ test_ok &= test::real::test_case_00903_zeta_neg_x (b_write_output);
return test_ok;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk