// Test a short NS missing a trailing null TEST(DBMessage1, BadNS) { BufBuilder b; b.appendNum(static_cast<int>(1)); b.appendChar('b'); b.appendChar('a'); b.appendChar('d'); // Forget to append \0 Message toSend; toSend.setData(dbDelete, b.buf(), b.len()); ASSERT_THROWS(DbMessage d1(toSend), UserException); }
// Test if the reserved field is short of 4 bytes TEST(DBMessage1, ShortFlags) { BufBuilder b; string ns("test"); b.appendChar(1); Message toSend; toSend.setData(dbDelete, b.buf(), b.len()); ASSERT_THROWS(DbMessage d1(toSend), UserException); }