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