summaryrefslogtreecommitdiffstats
path: root/util/system/error_ut.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/system/error_ut.cpp
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/system/error_ut.cpp')
-rw-r--r--util/system/error_ut.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/util/system/error_ut.cpp b/util/system/error_ut.cpp
new file mode 100644
index 00000000000..763b0dddb79
--- /dev/null
+++ b/util/system/error_ut.cpp
@@ -0,0 +1,41 @@
+#include "error.h"
+
+#include <library/cpp/testing/unittest/registar.h>
+
+#include <util/generic/ylimits.h>
+
+#ifdef _win_
+ #include "winint.h"
+#else
+ #include <fcntl.h>
+#endif
+
+class TSysErrorTest: public TTestBase {
+ UNIT_TEST_SUITE(TSysErrorTest);
+ UNIT_TEST(TestErrorCode)
+ UNIT_TEST(TestErrorMessage)
+ UNIT_TEST_SUITE_END();
+
+private:
+ inline void TestErrorCode() {
+ GenFailure();
+
+ UNIT_ASSERT(LastSystemError() != 0);
+ }
+
+ inline void TestErrorMessage() {
+ GenFailure();
+
+ UNIT_ASSERT(*LastSystemErrorText() != 0);
+ }
+
+ inline void GenFailure() {
+#ifdef _win_
+ SetLastError(3);
+#else
+ UNIT_ASSERT(open("/non-existent", O_RDONLY) < 0);
+#endif
+ }
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TSysErrorTest);