aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/gmock_in_unittest/events.cpp
blob: dbd65b727d7440365add04c6a7af48e60d75aa75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "events.h"

#include <library/cpp/testing/unittest/registar.h>

#include <util/generic/strbuf.h>
#include <util/generic/string.h>
#include <util/string/builder.h>

void TGMockTestEventListener::OnTestPartResult(const testing::TestPartResult& result) {
    if (result.failed()) {
        const TString message = result.message();
        const TString summary = result.summary();
        TStringBuilder msg;
        if (result.file_name())
            msg << result.file_name() << TStringBuf(":");
        if (result.line_number() != -1)
            msg << result.line_number() << TStringBuf(":");
        if (summary) {
            if (msg) {
                msg << TStringBuf("\n");
            }
            msg << summary;
        }
        if (message && summary != message) {
            if (msg) {
                msg << TStringBuf("\n");
            }
            msg << message;
        }
        NUnitTest::NPrivate::RaiseError(result.summary(), msg, result.fatally_failed());
    }
}