aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/unittest/checks.cpp
blob: 95baf5c9c212ba1a1b1c4c72848acd9300e1b88c (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
#include <util/generic/string.h>
#include <util/string/type.h>

bool CheckExceptionMessage(const char* msg, TString& err) {
    static const char* badMsg[] = {
        // Операция успешно завершена [cp1251]
        "\xce\xef\xe5\xf0\xe0\xf6\xe8\xff\x20\xf3\xf1\xef\xe5\xf8\xed\xee\x20\xe7\xe0\xe2\xe5\xf0\xf8\xe5\xed\xe0",
        "The operation completed successfully",
        "No error"}; 

    err.clear();

    if (msg == nullptr) {
        err = "Error message is null";
        return false;
    }

    if (IsSpace(msg)) {
        err = "Error message is empty";
        return false;
    }

    for (auto& i : badMsg) {
        if (strstr(msg, i) != nullptr) {
            err = "Invalid error message: " + TString(msg);
            return false;
        }
    }

    return true;
}