OLD | NEW |
1 /** | 1 /** |
2 * \file exception_test.cpp Unit tests for the library-wide exception classes in
installer-lib.h | 2 * \file exception_test.cpp Unit tests for the library-wide exception classes in
installer-lib.h |
3 */ | 3 */ |
4 | 4 |
5 #include <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
6 | 6 |
7 #include <Windows.h> | 7 #include <Windows.h> |
8 | 8 |
9 #include "../installer-lib.h" | 9 #include "../installer-lib.h" |
10 | 10 |
11 TEST(Exception_Test, empty_two) | 11 TEST(ExceptionTest, EmptyTwo) |
12 { | 12 { |
13 ::SetLastError(0); | 13 ::SetLastError(0); |
14 WindowsApiError e("", ""); | 14 WindowsApiError e("", ""); |
15 ASSERT_STREQ("<unspecified> returned <unknown> with last error code 0", e.what
()); | 15 ASSERT_STREQ("<unspecified> returned <unknown> with last error code 0", e.what
()); |
16 } | 16 } |
17 | 17 |
18 TEST(Exception_Test, empty_three) | 18 TEST(ExceptionTest, EmptyThree) |
19 { | 19 { |
20 ::SetLastError(1); | 20 ::SetLastError(1); |
21 WindowsApiError e("", "", ""); | 21 WindowsApiError e("", "", ""); |
22 ASSERT_STREQ("<unspecified> returned <unknown> with last error code 1", e.what
()); | 22 ASSERT_STREQ("<unspecified> returned <unknown> with last error code 1", e.what
()); |
23 } | 23 } |
24 | 24 |
25 TEST(Exception_Test, empty_empty_message) | 25 TEST(ExceptionTest, EmptyEmptyMessage) |
26 { | 26 { |
27 ::SetLastError(2); | 27 ::SetLastError(2); |
28 WindowsApiError e("", "", "message"); | 28 WindowsApiError e("", "", "message"); |
29 ASSERT_STREQ("<unspecified> returned <unknown> with last error code 2: message
", e.what()); | 29 ASSERT_STREQ("<unspecified> returned <unknown> with last error code 2: message
", e.what()); |
30 } | 30 } |
31 | 31 |
32 TEST(Exception_Test, string_number) | 32 TEST(ExceptionTest, StringNumber) |
33 { | 33 { |
34 ::SetLastError(3); | 34 ::SetLastError(3); |
35 WindowsApiError e("Beep", 1); | 35 WindowsApiError e("Beep", 1); |
36 ASSERT_STREQ("Beep returned 1 with last error code 3", e.what()); | 36 ASSERT_STREQ("Beep returned 1 with last error code 3", e.what()); |
37 } | 37 } |
38 | 38 |
39 TEST(Exception_Test, string_number_message) | 39 TEST(ExceptionTest, StringNumberMessage) |
40 { | 40 { |
41 ::SetLastError(4); | 41 ::SetLastError(4); |
42 WindowsApiError e("Beep", 1, "message"); | 42 WindowsApiError e("Beep", 1, "message"); |
43 ASSERT_STREQ("Beep returned 1 with last error code 4: message", e.what()); | 43 ASSERT_STREQ("Beep returned 1 with last error code 4: message", e.what()); |
44 } | 44 } |
45 | 45 |
46 TEST(Exception_Test, string_string) | 46 TEST(ExceptionTest, StringString) |
47 { | 47 { |
48 ::SetLastError(5); | 48 ::SetLastError(5); |
49 WindowsApiError e("GetErrorMode", "SEM_FAILCRITICALERRORS"); | 49 WindowsApiError e("GetErrorMode", "SEM_FAILCRITICALERRORS"); |
50 ASSERT_STREQ("GetErrorMode returned SEM_FAILCRITICALERRORS with last error cod
e 5", e.what()); | 50 ASSERT_STREQ("GetErrorMode returned SEM_FAILCRITICALERRORS with last error cod
e 5", e.what()); |
51 } | 51 } |
52 | 52 |
53 TEST(Exception_Test, string_string_message) | 53 TEST(ExceptionTest, StringStringMessage) |
54 { | 54 { |
55 ::SetLastError(6); | 55 ::SetLastError(6); |
56 WindowsApiError e("GetErrorMode", "SEM_FAILCRITICALERRORS", "message"); | 56 WindowsApiError e("GetErrorMode", "SEM_FAILCRITICALERRORS", "message"); |
57 ASSERT_STREQ("GetErrorMode returned SEM_FAILCRITICALERRORS with last error cod
e 6: message", e.what()); | 57 ASSERT_STREQ("GetErrorMode returned SEM_FAILCRITICALERRORS with last error cod
e 6: message", e.what()); |
58 } | 58 } |
OLD | NEW |