Same issues as
Printer.It would be reasonable to merge the
extract_idandis_expected_idinto one function. This means we don't return state that may or may not be valid and then have to pass it into a separate function to check. Sticking with the input operator conventions, we get:std::istream& extract_id(std::istream& is, std::string& id, std::string const& expected_id);. We can use the state of the stream to indicate success / failure, and don't need the extra boolean. e.g.:std::string id; if (!extract_id(is, id, last_id)) // checks stream fail / bad bits (eof will be caught at next read) return is;One test-case with valid input calling the high-level stream operator is not enough to properly confirm the behavior. We need to check the behavior of the individual functions and think about edge cases. For example, for the
extract_idfunction, one might expect the following:TEST(Test_Reader, IStreamWithValidIDAndDot) { ... } TEST(Test_Reader, IStreamWithOnlyDot) { ... } TEST(Test_Reader, IStreamWithIDAndNoDot) { ... } TEST(Test_Reader, EmptyIStream) { ... } TEST(Test_Reader, IStreamWithValidIDAndDotAndBadbitSet) { ... } TEST(Test_Reader, IStreamWithValidIDAndDotAndFailitSet) { ... } TEST(Test_Reader, IStreamWithValidIDAndDotAndEofbitSet) { ... }discard, notdischard.Extra parentheses in
FakeType::insert()andEnableValve::insert():void insert(std::string(s)) { m = s; }It's fine to take the argument by value, but we can then move it into place:
void insert(std::string s) { m = std::move(s); }We have an
operator>>for theFakeTypes, but we aren't using it?I think we only need to set
last_idonce for a given datablock.