Skip to content

Find method to clarify gtest output statements. #7

Open

Description

@SanTransisco

Generally, we can perform the tests then the test will give an output on how the test failed. But, this isn't immediately clear to the students sometimes. We have been getting by doing

ASSERT_EQ(output, expected) <<outputMessage;

but we should see if we can find a way to better communicate to the students where, and how they went wrong.
Here is the code I've been using so far for analyzing standard output, but its gonna need some work for sure.

#define ASSERT_STD_OUTPUT_MSG(expected,outputmessage, func) { \
  std::stringstream ss; \
  auto old_buf = std::cout.rdbuf(ss.rdbuf()); \
  func(); \
  std::cout.rdbuf(old_buf); \
  std::string output = ss.str(); \
  ASSERT_EQ(output, expected) << outputmessage; \
}

Activity

  1. pinventado commented on Aug 9, 2019

    @pinventado
    Member

    We probably want to refactor the code that is currently used to fit into the pattern of EXPECT_PRED_FORMAT*. I've started doing this here:

    https://github.com/ILXL/cpp-code-analyzer/blob/7b2b1957678d6a7369eb7e73f7d43b7346473aea/src/test/gtest_ext.h#L196

    but need to reflect it in the other macros. Using this pattern should allow us to attach additional output messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions