Permalink
Browse files

+ update conversion tests to have 0.0 and negative numbers

  • Loading branch information...
artemp committed Dec 14, 2012
1 parent bc9be37 commit 9453d93f1508fa0e9e7cc45ae7798a329f0d62af
Showing with 39 additions and 0 deletions.
  1. +39 −0 tests/cpp_tests/conversions_test.cpp
@@ -10,39 +10,74 @@ int main( int, char*[] )
std::string out;
// Test double
+ to_string(out, double(0));
+ BOOST_TEST_EQ( out, "0" );
+ out.clear();
to_string(out, double(1));
BOOST_TEST_EQ( out, "1" );
out.clear();
+ to_string(out, double(-1));
+ BOOST_TEST_EQ( out, "-1" );
+ out.clear();
+
to_string(out, double(0.1));
BOOST_TEST_EQ( out, "0.1" );
out.clear();
+ to_string(out, double(-0.1));
+ BOOST_TEST_EQ( out, "-0.1" );
+ out.clear();
+
to_string(out, double(0.123));
BOOST_TEST_EQ( out, "0.123" );
out.clear();
+ to_string(out, double(-0.123));
+ BOOST_TEST_EQ( out, "-0.123" );
+ out.clear();
+
to_string(out, double(1e-06));
BOOST_TEST_EQ( out, "1e-06" );
out.clear();
+ to_string(out, double(-1e-06));
+ BOOST_TEST_EQ( out, "-1e-06" );
+ out.clear();
+
to_string(out, double(1e-05));
BOOST_TEST_EQ( out, "0.00001" );
out.clear();
+ to_string(out, double(-1e-05));
+ BOOST_TEST_EQ( out, "-0.00001" );
+ out.clear();
+
to_string(out, double(0.0001));
BOOST_TEST_EQ( out, "0.0001" );
out.clear();
+ to_string(out, double(-0.0001));
+ BOOST_TEST_EQ( out, "-0.0001" );
+ out.clear();
+
to_string(out, double(0.0001234567890123456));
BOOST_TEST_EQ( out, "0.0001234567890123456" );
out.clear();
+ to_string(out, double(-0.0001234567890123456));
+ BOOST_TEST_EQ( out, "-0.0001234567890123456" );
+ out.clear();
+
to_string(out, double(1000000000000000));
BOOST_TEST_EQ( out, "1000000000000000" );
out.clear();
+ to_string(out, double(-1000000000000000));
+ BOOST_TEST_EQ( out, "-1000000000000000" );
+ out.clear();
+
to_string(out, double(100000000000000.1));
BOOST_TEST_EQ( out, "100000000000000.1" );
out.clear();
@@ -59,6 +94,10 @@ int main( int, char*[] )
BOOST_TEST_EQ( out, "1.234e+16" );
out.clear();
+ to_string(out, double(-1.234e+16));
+ BOOST_TEST_EQ( out, "-1.234e+16" );
+ out.clear();
+
// Test int
to_string(out, int(2));

0 comments on commit 9453d93

Please sign in to comment.