aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/unittest/checks.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/testing/unittest/checks.cpp
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/testing/unittest/checks.cpp')
-rw-r--r--library/cpp/testing/unittest/checks.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp
new file mode 100644
index 00000000000..c5712ae9d21
--- /dev/null
+++ b/library/cpp/testing/unittest/checks.cpp
@@ -0,0 +1,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;
+}