Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find method to clarify gtest output statements. #7

Open
SanTransisco opened this issue Sep 24, 2018 · 1 comment
Open

Find method to clarify gtest output statements. #7

SanTransisco opened this issue Sep 24, 2018 · 1 comment

Comments

@SanTransisco
Copy link

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; \
}
@pinventado
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants