Selaa lähdekoodia

Merge branch 'file-exception-improvement' of public/ls-standard-library into development

patrick-christopher.mattulat 1 vuosi sitten
vanhempi
commit
5efb10ea00
3 muutettua tiedostoa jossa 13 lisäystä ja 4 poistoa
  1. 1 0
      README.md
  2. 3 3
      source/ls-std/io/File.cpp
  3. 9 1
      test/cases/io/FileTest.cpp

+ 1 - 0
README.md

@@ -49,6 +49,7 @@ A __Date__ class comes with this submodule, which you can use to represent a dat
 - __NullPointerEvaluator__ & __NullPointerArgumentEvaluator__ now except raw pointers
 - Section-Pair identifiers can now have a length of 64 characters
 - Section-Pair values can now have a length of 512 characters
+- exceptions for creation of files or directories have been improved and now show the absolute file path
 
 #### Fixes ####
 

+ 3 - 3
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"};
   }
 }
 
@@ -208,7 +208,7 @@ void File::makeDirectory()
 {
   if (!File::_makeDirectory(this->absoluteFilePath))
   {
-    throw FileOperationException{"operation: create directory"};
+    throw FileOperationException{R"lit(directory ")lit" + this->absoluteFilePath + R"lit(" could not be created!)lit"};
   }
 }
 

+ 9 - 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;
           }
         },
@@ -318,6 +322,10 @@ namespace
           }
           catch (const FileOperationException &_exception)
           {
+            string expected = _exception.getName() + R"lit( thrown - directory ")lit" + TestHelper::getResourcesFolderLocation() + R"lit(list-test" could not be created!)lit";
+            string actual = _exception.what();
+
+            ASSERT_STREQ(expected.c_str(), actual.c_str());
             throw;
           }
         },