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( Exception_Test, empty_two ) |
12 { | 12 { |
13 ::SetLastError( 0 ) ; | 13 ::SetLastError( 0 ) ; |
14 windows_api_error e( "", "" ) ; | 14 WindowsApiError e( "", "" ) ; |
15 ASSERT_STREQ( "<unspecified> returned <unknown> with last error code 0", e.wha
t() ) ; | 15 ASSERT_STREQ( "<unspecified> returned <unknown> with last error code 0", e.wha
t() ) ; |
16 } | 16 } |
17 | 17 |
18 TEST( Exception_Test, empty_three ) | 18 TEST( Exception_Test, empty_three ) |
19 { | 19 { |
20 ::SetLastError( 1 ) ; | 20 ::SetLastError( 1 ) ; |
21 windows_api_error e( "", "", "" ) ; | 21 WindowsApiError e( "", "", "" ) ; |
22 ASSERT_STREQ( "<unspecified> returned <unknown> with last error code 1", e.wha
t() ) ; | 22 ASSERT_STREQ( "<unspecified> returned <unknown> with last error code 1", e.wha
t() ) ; |
23 } | 23 } |
24 | 24 |
25 TEST( Exception_Test, empty_empty_message ) | 25 TEST( Exception_Test, empty_empty_message ) |
26 { | 26 { |
27 ::SetLastError( 2 ) ; | 27 ::SetLastError( 2 ) ; |
28 windows_api_error e( "", "", "message" ) ; | 28 WindowsApiError e( "", "", "message" ) ; |
29 ASSERT_STREQ( "<unspecified> returned <unknown> with last error code 2: messag
e", e.what() ) ; | 29 ASSERT_STREQ( "<unspecified> returned <unknown> with last error code 2: messag
e", e.what() ) ; |
30 } | 30 } |
31 | 31 |
32 TEST( Exception_Test, string_number ) | 32 TEST( Exception_Test, string_number ) |
33 { | 33 { |
34 ::SetLastError( 3 ) ; | 34 ::SetLastError( 3 ) ; |
35 windows_api_error 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( Exception_Test, string_number_message ) |
40 { | 40 { |
41 ::SetLastError( 4 ) ; | 41 ::SetLastError( 4 ) ; |
42 windows_api_error 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( Exception_Test, string_string ) |
47 { | 47 { |
48 ::SetLastError( 5 ) ; | 48 ::SetLastError( 5 ) ; |
49 windows_api_error e( "GetErrorMode", "SEM_FAILCRITICALERRORS" ) ; | 49 WindowsApiError e( "GetErrorMode", "SEM_FAILCRITICALERRORS" ) ; |
50 ASSERT_STREQ( "GetErrorMode returned SEM_FAILCRITICALERRORS with last error co
de 5", e.what() ) ; | 50 ASSERT_STREQ( "GetErrorMode returned SEM_FAILCRITICALERRORS with last error co
de 5", e.what() ) ; |
51 } | 51 } |
52 | 52 |
53 TEST( Exception_Test, string_string_message ) | 53 TEST( Exception_Test, string_string_message ) |
54 { | 54 { |
55 ::SetLastError( 6 ) ; | 55 ::SetLastError( 6 ) ; |
56 windows_api_error e( "GetErrorMode", "SEM_FAILCRITICALERRORS", "message" ) ; | 56 WindowsApiError e( "GetErrorMode", "SEM_FAILCRITICALERRORS", "message" ) ; |
57 ASSERT_STREQ( "GetErrorMode returned SEM_FAILCRITICALERRORS with last error co
de 6: message", e.what() ) ; | 57 ASSERT_STREQ( "GetErrorMode returned SEM_FAILCRITICALERRORS with last error co
de 6: message", e.what() ) ; |
58 } | 58 } |
OLD | NEW |