Explorar o código

Improve file creation exception

Patrick-Christopher Mattulat hai 1 ano
pai
achega
eb20841c7b
Modificáronse 2 ficheiros con 7 adicións e 3 borrados
  1. 2 2
      source/ls-std/io/File.cpp
  2. 5 1
      test/cases/io/FileTest.cpp

+ 2 - 2
source/ls-std/io/File.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-15
- * Changed:         2023-02-24
+ * Changed:         2023-04-13
  *
  * */
 
@@ -99,7 +99,7 @@ void File::createNewFile()
   }
   else
   {
-    throw FileOperationException{"operation: create new file"};
+    throw FileOperationException{R"lit(file ")lit" + this->absoluteFilePath + R"lit(" could not be created!)lit"};
   }
 }
 

+ 5 - 1
test/cases/io/FileTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-15
- * Changed:         2023-03-25
+ * Changed:         2023-04-13
  *
  * */
 
@@ -147,6 +147,10 @@ namespace
           }
           catch (const FileOperationException &_exception)
           {
+            string expected = _exception.getName() + R"lit( thrown - file ")lit" + TestHelper::getResourcesFolderLocation() + R"lit(simple.txt" could not be created!)lit";
+            string actual = _exception.what();
+
+            ASSERT_STREQ(expected.c_str(), actual.c_str());
             throw;
           }
         },