delete tds;
}
- void SetUp() {
- // There are blocking reads in some tests. We want to have a safety
- // catch in case the sender didn't write enough. We set a timeout of
- // 10 seconds per one test (which should really be enough even on
- // slow machines). If the timeout happens, it kills the test and
- // the whole test fails.
- //alarm(10);
- }
-
- void TearDown() {
- // Cancel the timeout scheduled in SetUp. We don't want to kill any
- // of the other tests by it by accident.
- alarm(0);
- }
-
// Check two elements are equal
- void elementsEqual(const ConstElementPtr& expected,
- const ConstElementPtr& actual) const
- {
- EXPECT_TRUE(expected->equals(*actual)) <<
- "Elements differ, expected: " << expected->toWire() <<
- ", got: " << actual->toWire();
- }
-
- // The same, but with one specified as string
void elementsEqual(const string& expected,
- const ConstElementPtr& actual)
+ const ConstElementPtr& actual) const
{
- const ConstElementPtr expected_el(Element::fromJSON(expected));
- elementsEqual(expected_el, actual);
+ EXPECT_TRUE(Element::fromJSON(expected)->equals(*actual)) <<
+ "Elements differ, expected: " << expected <<
+ ", got: " << actual->toWire();
}
// Check the session sent a message with the given header. The
// message is hardcoded.
void checkSentMessage(const string& expected_hdr,
- const char* description)
+ const char* description) const
{
SCOPED_TRACE(description);
- const SentMessage msg(tds->readmsg());
+ const SentMessage &msg(sess.getSentMessage());
elementsEqual(expected_hdr, msg.first);
elementsEqual("{\"test\": 42}", msg.second);
}