parent
71109fa551
commit
5a6cd4b0f2
18 changed files with 333 additions and 115 deletions
|
|
@ -45,3 +45,42 @@ TTS_CASE_TPL("I/O for map test", rotgen::tests::types)
|
|||
if constexpr(O::value) TTS_EQUAL(os.str(), std::string{"1 2\n3 4"});
|
||||
else TTS_EQUAL(os.str(), std::string{"1 3\n2 4"});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("I/O using format", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::ioformat io(rotgen::StreamPrecision, 0, ", ", ";\n", "<", ">", "[", "]");
|
||||
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> x({ {1,2} , {3,4} });
|
||||
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << rotgen::format(x,io);
|
||||
TTS_EQUAL(os.str(), std::string{"[<1, 2>;\n <3, 4>]"});
|
||||
}
|
||||
|
||||
rotgen::map<rotgen::matrix<T,2,2,O::value>> m{x.data()};
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << rotgen::format(m,io);
|
||||
TTS_EQUAL(os.str(), std::string{"[<1, 2>;\n <3, 4>]"});
|
||||
}
|
||||
|
||||
auto b = rotgen::extract(x,0,0,2,2);
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << rotgen::format(b,io);
|
||||
TTS_EQUAL(os.str(), std::string{"[<1, 2>;\n <3, 4>]"});
|
||||
}
|
||||
|
||||
auto printer = [&](rotgen::ref<const rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>> r)
|
||||
{
|
||||
std::ostringstream st;
|
||||
st << rotgen::format(r,io);
|
||||
return st.str();
|
||||
};
|
||||
|
||||
TTS_EQUAL(printer(x), std::string{"[<1, 2>;\n <3, 4>]"});
|
||||
TTS_EQUAL(printer(m), std::string{"[<1, 2>;\n <3, 4>]"});
|
||||
TTS_EQUAL(printer(b), std::string{"[<1, 2>;\n <3, 4>]"});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue