#include <iomanip>
#include "Format.hh"
#include <boost/cstdint.hpp>
+#include "String.hh"
#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-BOOST_AUTO_UNIT_TEST(formatEng)
+SENF_AUTO_UNIT_TEST(formatEng)
{
std::stringstream ss;
ss << std::showbase << senf::format::eng(12345,67);
BOOST_CHECK_EQUAL( ss.str(), "12.345+-0.067k" );
}
+
+ // class member formatting
+ BOOST_CHECK_EQUAL( senf::str(senf::format::eng(12345, 67)
+ .setw()
+ .setprecision(5)
+ .setfill('0')
+ .showbase()
+ .showpos()
+ .internal()),
+ "+012.35+-000.07k" );
+
+ BOOST_CHECK_EQUAL( senf::str(senf::format::eng(12.345, 67)
+ .setw()
+ .setprecision(5)
+ .showpoint()
+ .uppercase()),
+ " 12.35+-067.00E+00" );
}
-BOOST_AUTO_UNIT_TEST(dumpint)
+SENF_AUTO_UNIT_TEST(dumpint)
{
std::stringstream ss;
# undef CheckFormat
}
+namespace {
+ void f1(std::ostream & os) {
+ senf::format::IndentHelper indent;
+ os << indent << "f1\n";
+ }
+ void f2(std::ostream & os) {
+ senf::format::IndentHelper indent;
+ os << indent << "f2_1\n";
+ f1( os);
+ os << indent << "f2_2\n";
+ indent.increase();
+ os << indent << "f2_3\n";
+ }
+}
+SENF_AUTO_UNIT_TEST(indent)
+{
+ std::stringstream ss;
+ f2(ss);
+ BOOST_CHECK_EQUAL( ss.str(),
+ " f2_1\n"
+ " f1\n"
+ " f2_2\n"
+ " f2_3\n");
+}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_