events.cpp 1003 B

1234567891011121314151617181920212223242526272829303132
  1. #include "events.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. #include <util/generic/strbuf.h>
  4. #include <util/generic/string.h>
  5. #include <util/string/builder.h>
  6. void TGMockTestEventListener::OnTestPartResult(const testing::TestPartResult& result) {
  7. if (result.failed()) {
  8. const TString message = result.message();
  9. const TString summary = result.summary();
  10. TStringBuilder msg;
  11. if (result.file_name())
  12. msg << result.file_name() << TStringBuf(":");
  13. if (result.line_number() != -1)
  14. msg << result.line_number() << TStringBuf(":");
  15. if (summary) {
  16. if (msg) {
  17. msg << TStringBuf("\n");
  18. }
  19. msg << summary;
  20. }
  21. if (message && summary != message) {
  22. if (msg) {
  23. msg << TStringBuf("\n");
  24. }
  25. msg << message;
  26. }
  27. NUnitTest::NPrivate::RaiseError(result.summary(), msg, result.fatally_failed());
  28. }
  29. }