@@ -97,6 +97,22 @@ void test_puzzle_initial_state_isnt_set_due_to_incorrect_values() {
9797 if (exception_not_thrown) assert (false );
9898}
9999
100+ void test_exception_is_thrown_if_file_doesnt_exist () {
101+ /* We check if the set_initial_state_from_file() function
102+ * throws an std::invalid_argument exception if the file doesn't exist. */
103+
104+ bool exception_not_thrown = true ;
105+ sudoku::Grid grid_from_file;
106+
107+ try {
108+ grid_from_file.set_initial_state_from_file (" some_random_thing.txt" );
109+ } catch (std::invalid_argument ia) {
110+ exception_not_thrown = false ;
111+ }
112+
113+ if (exception_not_thrown) assert (false );
114+ }
115+
100116void test_value_exists_in_column () {
101117 /* We check functionality of the value_exists_in_column function. */
102118 sudoku::Grid grid ({{
@@ -354,6 +370,7 @@ int main() {
354370 test_puzzle_initial_state_is_set_correctly,
355371 test_puzzle_initial_state_is_set_correctly_from_file,
356372 test_puzzle_initial_state_isnt_set_due_to_incorrect_values,
373+ test_exception_is_thrown_if_file_doesnt_exist,
357374 test_value_exists_in_column,
358375 test_value_exists_in_row,
359376 test_value_exists_in_3x3_grid,
0 commit comments