diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-08-03 23:29:33 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-08-03 23:29:33 +0200 |
commit | 2addc7763556ff76809f14e2063d1452aa9d6275 (patch) | |
tree | 996cac9cfa3c18798b5e509f51935a2538baac3f /tests | |
parent | 2f6f6bdbb191aca01a1c4a9587e314442d219fb4 (diff) |
Fix crash for empty/invalid/not-found filepaths
Add tests to validate empty string path
Add tests to validate non-existent string path
Add tests to validate nullptr buffer parser
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/csv/Parser.cpp | 24 | ||||
-rw-r--r-- | tests/src/v2script/Parser.cpp | 24 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/src/csv/Parser.cpp b/tests/src/csv/Parser.cpp index fe26726..88a1474 100644 --- a/tests/src/csv/Parser.cpp +++ b/tests/src/csv/Parser.cpp @@ -48,6 +48,14 @@ TEST_CASE("CSV Memory Buffer (begin, end) Parse", "[csv-memory-parse][buffer][be CHECK_PARSE(false); } +TEST_CASE("CSV Buffer nullptr Parse", "[csv-memory-parse][buffer][nullptr]") { + Parser parser(ovdl::detail::cnull); + + parser.load_from_buffer(nullptr, std::size_t { 0 }); + + CHECK_PARSE(true); +} + TEST_CASE("CSV Memory String Parse", "[csv-memory-parse][string]") { Parser parser(ovdl::detail::cnull); @@ -152,6 +160,22 @@ TEST_CASE("CSV File (HasCstr) Handle String Parse", "[csv-file-parse][handle-str CHECK_PARSE(true); } +TEST_CASE("CSV File (const char*) Handle Empty Path String Parse", "[csv-file-parse][handle-string][char-ptr][empty-path]") { + Parser parser(ovdl::detail::cnull); + + parser.load_from_file(""); + + CHECK_OR_RETURN(!parser.get_errors().empty()); +} + +TEST_CASE("CSV File (const char*) Handle Non-existent Path String Parse", "[csv-file-parse][handle-string][char-ptr][nonexistent-path]") { + Parser parser(ovdl::detail::cnull); + + parser.load_from_file("./Idontexist"); + + CHECK_OR_RETURN(!parser.get_errors().empty()); +} + TEST_CASE("CSV Parse", "[csv-parse]") { Parser parser(ovdl::detail::cnull); diff --git a/tests/src/v2script/Parser.cpp b/tests/src/v2script/Parser.cpp index 5ddc49d..856e5fb 100644 --- a/tests/src/v2script/Parser.cpp +++ b/tests/src/v2script/Parser.cpp @@ -54,6 +54,14 @@ TEST_CASE("V2Script Memory Buffer String Simple Parse", "[v2script-memory-simple CHECK_PARSE(); } +TEST_CASE("V2Script Buffer nullptr Simple Parse", "[v2script-memory-simple-parse][buffer][nullptr]") { + Parser parser(ovdl::detail::cnull); + + parser.load_from_buffer(nullptr, std::size_t { 0 }); + + CHECK_PARSE(); +} + TEST_CASE("V2Script File (const char*) Simple Parse", "[v2script-file-simple-parse][char-ptr]") { SetupFile(simple_path); @@ -90,6 +98,22 @@ TEST_CASE("V2Script File (HasCstr) Simple Parse", "[v2script-file-simple-parse][ CHECK_PARSE(); } +TEST_CASE("V2Script File (const char*) Handle Empty Path String Parse", "[v2script-file-parse][handle-string][char-ptr][empty-path]") { + Parser parser(ovdl::detail::cnull); + + parser.load_from_file(""); + + CHECK_OR_RETURN(!parser.get_errors().empty()); +} + +TEST_CASE("V2Script File (const char*) Handle Non-existent Path String Parse", "[v2script-file-parse][handle-string][char-ptr][nonexistent-path]") { + Parser parser(ovdl::detail::cnull); + + parser.load_from_file("./Idontexist"); + + CHECK_OR_RETURN(!parser.get_errors().empty()); +} + TEST_CASE("V2Script Identifier Simple Parse", "[v2script-id-simple-parse]") { Parser parser(ovdl::detail::cnull); |