move cout string to print function

release/4.3a0
mxie32 2019-06-16 10:31:35 -04:00
parent c087dd336b
commit 45244d3ffd
2 changed files with 3 additions and 3 deletions

View File

@ -130,8 +130,6 @@ namespace gtsam {
/* ************************************************************************* */
ostream& operator<<(ostream& os, const VectorValues& v) {
os << "VectorValues"
<< ": " << v.size() << " elements\n";
// Change print depending on whether we are using TBB
#ifdef GTSAM_USE_TBB
map<Key, Vector> sorted;
@ -152,6 +150,7 @@ namespace gtsam {
/* ************************************************************************* */
void VectorValues::print(const string& str,
const KeyFormatter& formatter) const {
cout << str << ": " << size() << " elements\n";
cout << *this;
cout.flush();
}

View File

@ -239,9 +239,10 @@ TEST(VectorValues, print)
vv.insert(2, Vector2(4, 5));
vv.insert(5, Vector2(6, 7));
vv.insert(7, Vector2(8, 9));
vv.print();
string expected =
"VectorValues: 5 elements\n 0: 1\n 1: 2 3\n 2: 4 5\n 5: 6 7\n 7: 8 9\n";
" 0: 1\n 1: 2 3\n 2: 4 5\n 5: 6 7\n 7: 8 9\n";
stringstream actual;
actual << vv;
EXPECT(expected == actual.str());