From 00fd5391feece1abf612ebac4e262c3d5b30ea26 Mon Sep 17 00:00:00 2001 From: SinaKarvandi Date: Tue, 13 Aug 2024 19:46:37 +0900 Subject: [PATCH] add more test cases for the command parser --- .../hyperdbg-test/code/tests/test-parser.cpp | 10 ++-- .../command-parser-testcases.txt | 46 ++++++++++++++++++- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/hyperdbg/hyperdbg-test/code/tests/test-parser.cpp b/hyperdbg/hyperdbg-test/code/tests/test-parser.cpp index 9aae44a0..a20beac1 100644 --- a/hyperdbg/hyperdbg-test/code/tests/test-parser.cpp +++ b/hyperdbg/hyperdbg-test/code/tests/test-parser.cpp @@ -25,14 +25,14 @@ createTestCaseArray(const std::vector & testCases) // // Allocate memory for the array of pointers (size: number of test cases) // - CHAR_PTR_PTR testCaseArray = new char *[testCases.size()]; + CHAR_PTR_PTR testCaseArray = (CHAR_PTR_PTR)malloc(testCases.size() * sizeof(UINT64)); // // Allocate memory for each string and copy the content // for (size_t i = 0; i < testCases.size(); ++i) { - testCaseArray[i] = new char[testCases[i].length() + 1]; // +1 for the null terminator + testCaseArray[i] = (char *)malloc(testCases[i].length() + 1); // +1 for the null terminator std::strcpy(testCaseArray[i], testCases[i].c_str()); } @@ -54,13 +54,13 @@ freeTestCaseArray(CHAR_PTR_PTR testCaseArray, size_t size) // for (size_t i = 0; i < size; ++i) { - delete[] testCaseArray[i]; + free(testCaseArray[i]); } // // Free the array of pointers // - delete[] testCaseArray; + free(testCaseArray); } /** @@ -304,7 +304,7 @@ TestCommandParser() // // Clean up memory // - freeTestCaseArray(testCaseArray, testCases.size()); + freeTestCaseArray(testCaseArray, testCase.second.size()); } return overallResult; diff --git a/hyperdbg/tests/command-parser/command-parser-testcases.txt b/hyperdbg/tests/command-parser/command-parser-testcases.txt index aa5443e4..8fb208dd 100644 --- a/hyperdbg/tests/command-parser/command-parser-testcases.txt +++ b/hyperdbg/tests/command-parser/command-parser-testcases.txt @@ -45,4 +45,48 @@ script @rax= @rbx; printf("ho"); - \ No newline at end of file + +_____________________________________________________________ + + + + + +!monitor 123 1234 script { tesTo salam + +khoobi? + } +---------------------------------- +!monitor +---------------------------------- +123 +---------------------------------- +1234 +---------------------------------- +script +---------------------------------- + tesTo salam + +khoobi? + +_____________________________________________________________ + help settings +---------------------------------- +help +---------------------------------- +settings +_____________________________________________________________ +help settings +---------------------------------- +help +---------------------------------- +settings +_____________________________________________________________ + + f fsdfsdfds + + +---------------------------------- +f +---------------------------------- +fsdfsdfds \ No newline at end of file