From fc966f297cc163254220c930a565484abde207d9 Mon Sep 17 00:00:00 2001 From: Oskar Date: Sun, 18 Feb 2024 18:42:40 +0100 Subject: Organised test directory and did some logic fixes to smode --- input.c | 15 +++++++++++ test/endnewlinetest | 3 --- test/file.txt | 26 ------------------- test/file2.txt | 23 ----------------- test/newlinetest | 10 -------- test/newlinetest2 | 10 -------- test/noline | 1 - test/smode | Bin 25488 -> 0 bytes test/testcases/smode_cases.txt | 16 ++++++++++++ test/testgetline.c | 44 -------------------------------- test/testgrounds/endnewlinetest | 3 +++ test/testgrounds/file.txt | 26 +++++++++++++++++++ test/testgrounds/file2.txt | 23 +++++++++++++++++ test/testgrounds/newlinetest | 10 ++++++++ test/testgrounds/newlinetest2 | 10 ++++++++ test/testgrounds/noline | 1 + test/testgrounds/testgetline.c | 44 ++++++++++++++++++++++++++++++++ test/testgrounds/text_about_testing.txt | 27 ++++++++++++++++++++ test/text_about_testing.txt | 27 -------------------- 19 files changed, 175 insertions(+), 144 deletions(-) delete mode 100644 test/endnewlinetest delete mode 100644 test/file.txt delete mode 100644 test/file2.txt delete mode 100644 test/newlinetest delete mode 100644 test/newlinetest2 delete mode 100644 test/noline delete mode 100644 test/smode create mode 100644 test/testcases/smode_cases.txt delete mode 100644 test/testgetline.c create mode 100644 test/testgrounds/endnewlinetest create mode 100644 test/testgrounds/file.txt create mode 100644 test/testgrounds/file2.txt create mode 100644 test/testgrounds/newlinetest create mode 100644 test/testgrounds/newlinetest2 create mode 100644 test/testgrounds/noline create mode 100644 test/testgrounds/testgetline.c create mode 100644 test/testgrounds/text_about_testing.txt delete mode 100644 test/text_about_testing.txt diff --git a/input.c b/input.c index 2c7694d..6bae4b2 100644 --- a/input.c +++ b/input.c @@ -40,6 +40,8 @@ int smode_input_and_validator(char *single, char **multiple, uint64_t focus) { / path 3: If there is nothing else after the L (in this case just an L) then just return an L (DONE) */ + + // its already a clusterf##k of a function char nums[] = "123456789"; int L_num_flag = 2; int plus_num_flag = -1; //If true the if statement will validate if input is valid after the + @@ -47,10 +49,15 @@ int smode_input_and_validator(char *single, char **multiple, uint64_t focus) { / if (smode_buf[1] == '+') { printf("Its a plus!\n"); + plus_num_flag = 1; // Check if its a plus if (smode_buf[2] == '0') { L_num_flag = -1; // if 0 then its just invalid immediately } + if (smode_buf[2] != '\n') { // If there is no return we set these flags to false. + plus_num_flag = -1; // If there is a return then no flags are changed and thus we know that the input is only an L+ + L_num_flag = -1; + } for (int i = 0 ; i < 9 ; i++) { // Check if theres a number after + if (smode_buf[2] == nums[i]) { @@ -144,18 +151,26 @@ int smode_input_and_validator(char *single, char **multiple, uint64_t focus) { / if (L_num_flag == 0) { printf("Because the string was valid we return it here!\n"); // actually return the valid string here + break; } if (L_num_flag == -1) { printf("Because the string was invalid we return '?' here!\n"); // invalid! return '?' + break; } + if (plus_num_flag == 1) { + printf("L+ only!"); + break; + } if (smode_buf[1] == '\n') { printf("L only!\n"); // just return L + break; } + printf("Because the string was invalid we return '?' here!\n"); // Last catch, it it makes it to here then just invalid // if it gets to here then i guess we just return '?' diff --git a/test/endnewlinetest b/test/endnewlinetest deleted file mode 100644 index 1727e1a..0000000 --- a/test/endnewlinetest +++ /dev/null @@ -1,3 +0,0 @@ -And thus, the new line bug was fixed... I think. -aasadasdasd -asdasd \ No newline at end of file diff --git a/test/file.txt b/test/file.txt deleted file mode 100644 index 6f741aa..0000000 --- a/test/file.txt +++ /dev/null @@ -1,26 +0,0 @@ - - -lksdjflsdjfls209432+093+20943????01+230+2,.,-.,-,-.,-.,.,..,.,.,¨.¨,¨.,¨.´.´,´.,´.,´.´,.´,.´.´,´.????`?`?`?`?`?`?`?`?`???????!!!!!!!! -öölaölskdöaslkölaksöd -+10230123203293 -())()()()()&&&&&///////////////&%/&/&&%%&/%/// 3 -=)(09820398409709 -zxm,czm.x,cm.zxmc.,.... -This is line 9 -::: - -.salksjdlkajs -las - - -alskdasldkasöld - - - -. - -LINE 22!!!!!!! - -ast line!!! - - diff --git a/test/file2.txt b/test/file2.txt deleted file mode 100644 index 73ee54a..0000000 --- a/test/file2.txt +++ /dev/null @@ -1,23 +0,0 @@ -asldaskdlalksjd -11111111 -222222 -öölaölskdöaslkölaksöd -+10230123203293 -()))&%#"#¤%&/&%¤ -=)(09820398409709 -zxm,czm.x,cm.zxmc.,.... -: -::: - -.salksjdlkajs -las - - -alskdasldkasöld - - - - - - -ölasdlkaösldköalskdöals3925748392 diff --git a/test/newlinetest b/test/newlinetest deleted file mode 100644 index f00c965..0000000 --- a/test/newlinetest +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 diff --git a/test/newlinetest2 b/test/newlinetest2 deleted file mode 100644 index f00c965..0000000 --- a/test/newlinetest2 +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 diff --git a/test/noline b/test/noline deleted file mode 100644 index 08a1db1..0000000 --- a/test/noline +++ /dev/null @@ -1 +0,0 @@ -asdasdasdasdasd \ No newline at end of file diff --git a/test/smode b/test/smode deleted file mode 100644 index 16fc213..0000000 Binary files a/test/smode and /dev/null differ diff --git a/test/testcases/smode_cases.txt b/test/testcases/smode_cases.txt new file mode 100644 index 0000000..435fb48 --- /dev/null +++ b/test/testcases/smode_cases.txt @@ -0,0 +1,16 @@ +Positive: +L expected result: L only +L+ expected result: L+ only +L+4 expected result: +++ Valid +L+34 expected result: +++ Valid +L+4467 expected result: +++ Valid +L24 expected result: Valid +L34553 expected result: Valid + +Negative: +LL expected result: Invalid +L0 expected result: Invalid +L+0 expected result: Invalid +L+l expected result: Invalid +L+35l expected result: Invalid +L23l expected result: Invalid diff --git a/test/testgetline.c b/test/testgetline.c deleted file mode 100644 index d186439..0000000 --- a/test/testgetline.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include -#include "7ed.h" - -#define USAGE "" -#define PROGRAM_NAME "7ed" - -int main (int argc, char *argv[]) { - - -int opt; -int returnval; -long focus = 100; -char *line; -while ((opt = getopt(argc, argv, "i:")) != -1) { - switch (opt) { - - case 'i': - - returnval = GET_LINE(optarg, focus, &line); - if (returnval == 1) { - return EXIT_FAILURE; - } - printf("%s", line); - free(line); - - break; - - default: - fprintf(stderr, "%s", USAGE); - return EXIT_FAILURE; - } -} - - if (argc == 1) { - fprintf(stderr, "%s: Please provide a file.\n%s", argv[0], USAGE); - return EXIT_FAILURE; - } - -return EXIT_SUCCESS; -// TEST! -// LINE 44 YOOOOOOOOOOOOOOO!! diff --git a/test/testgrounds/endnewlinetest b/test/testgrounds/endnewlinetest new file mode 100644 index 0000000..1727e1a --- /dev/null +++ b/test/testgrounds/endnewlinetest @@ -0,0 +1,3 @@ +And thus, the new line bug was fixed... I think. +aasadasdasd +asdasd \ No newline at end of file diff --git a/test/testgrounds/file.txt b/test/testgrounds/file.txt new file mode 100644 index 0000000..6f741aa --- /dev/null +++ b/test/testgrounds/file.txt @@ -0,0 +1,26 @@ + + +lksdjflsdjfls209432+093+20943????01+230+2,.,-.,-,-.,-.,.,..,.,.,¨.¨,¨.,¨.´.´,´.,´.,´.´,.´,.´.´,´.????`?`?`?`?`?`?`?`?`???????!!!!!!!! +öölaölskdöaslkölaksöd ++10230123203293 +())()()()()&&&&&///////////////&%/&/&&%%&/%/// 3 +=)(09820398409709 +zxm,czm.x,cm.zxmc.,.... +This is line 9 +::: + +.salksjdlkajs +las + + +alskdasldkasöld + + + +. + +LINE 22!!!!!!! + +ast line!!! + + diff --git a/test/testgrounds/file2.txt b/test/testgrounds/file2.txt new file mode 100644 index 0000000..73ee54a --- /dev/null +++ b/test/testgrounds/file2.txt @@ -0,0 +1,23 @@ +asldaskdlalksjd +11111111 +222222 +öölaölskdöaslkölaksöd ++10230123203293 +()))&%#"#¤%&/&%¤ +=)(09820398409709 +zxm,czm.x,cm.zxmc.,.... +: +::: + +.salksjdlkajs +las + + +alskdasldkasöld + + + + + + +ölasdlkaösldköalskdöals3925748392 diff --git a/test/testgrounds/newlinetest b/test/testgrounds/newlinetest new file mode 100644 index 0000000..f00c965 --- /dev/null +++ b/test/testgrounds/newlinetest @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/testgrounds/newlinetest2 b/test/testgrounds/newlinetest2 new file mode 100644 index 0000000..f00c965 --- /dev/null +++ b/test/testgrounds/newlinetest2 @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/testgrounds/noline b/test/testgrounds/noline new file mode 100644 index 0000000..08a1db1 --- /dev/null +++ b/test/testgrounds/noline @@ -0,0 +1 @@ +asdasdasdasdasd \ No newline at end of file diff --git a/test/testgrounds/testgetline.c b/test/testgrounds/testgetline.c new file mode 100644 index 0000000..d186439 --- /dev/null +++ b/test/testgrounds/testgetline.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include "7ed.h" + +#define USAGE "" +#define PROGRAM_NAME "7ed" + +int main (int argc, char *argv[]) { + + +int opt; +int returnval; +long focus = 100; +char *line; +while ((opt = getopt(argc, argv, "i:")) != -1) { + switch (opt) { + + case 'i': + + returnval = GET_LINE(optarg, focus, &line); + if (returnval == 1) { + return EXIT_FAILURE; + } + printf("%s", line); + free(line); + + break; + + default: + fprintf(stderr, "%s", USAGE); + return EXIT_FAILURE; + } +} + + if (argc == 1) { + fprintf(stderr, "%s: Please provide a file.\n%s", argv[0], USAGE); + return EXIT_FAILURE; + } + +return EXIT_SUCCESS; +// TEST! +// LINE 44 YOOOOOOOOOOOOOOO!! diff --git a/test/testgrounds/text_about_testing.txt b/test/testgrounds/text_about_testing.txt new file mode 100644 index 0000000..4857dfb --- /dev/null +++ b/test/testgrounds/text_about_testing.txt @@ -0,0 +1,27 @@ +Testing software is crucial for ensuring its functionality, reliability, and overall quality. + + + + + + + + + + +It serves as a safety net, catching errors and flaws before they reach end-users, which can ultimately save time, money, and reputation. + + +Firstly, software testing validates that the code functions as intended. It's like a quality control process that verifies if the software meets the specified requirements and performs the expected tasks accurately. By identifying and fixing bugs during testing, developers can prevent issues from surfacing when the software is in use, reducing the potential for disruptions or failures that could impact users. + +Secondly, testing helps enhance user experience. When software behaves consistently and predictably, users are more likely to have a positive experience. Comprehensive testing ensures that the software is user-friendly, intuitive, and responsive, which can significantly contribute to user satisfaction and retention. + +Moreover, testing aids in maintaining security and protecting sensitive data. Security vulnerabilities can be catastrophic, leading to breaches and compromises. Through rigorous testing, potential vulnerabilities can be identified and addressed, fortifying the software against potential cyber threats. + +Testing also supports scalability. It ensures that as the software grows or experiences increased usage, it continues to perform efficiently without compromising speed or functionality. This is particularly crucial in today's tech landscape, where scalability is often a key factor in a software's success. + +In essence, software testing isn't just about finding and fixing bugs. +It's a strategic process that enhances the overall quality, reliability, and security of software, contributing significantly to its success in the market and ensuring a positive user experience. + + + diff --git a/test/text_about_testing.txt b/test/text_about_testing.txt deleted file mode 100644 index 4857dfb..0000000 --- a/test/text_about_testing.txt +++ /dev/null @@ -1,27 +0,0 @@ -Testing software is crucial for ensuring its functionality, reliability, and overall quality. - - - - - - - - - - -It serves as a safety net, catching errors and flaws before they reach end-users, which can ultimately save time, money, and reputation. - - -Firstly, software testing validates that the code functions as intended. It's like a quality control process that verifies if the software meets the specified requirements and performs the expected tasks accurately. By identifying and fixing bugs during testing, developers can prevent issues from surfacing when the software is in use, reducing the potential for disruptions or failures that could impact users. - -Secondly, testing helps enhance user experience. When software behaves consistently and predictably, users are more likely to have a positive experience. Comprehensive testing ensures that the software is user-friendly, intuitive, and responsive, which can significantly contribute to user satisfaction and retention. - -Moreover, testing aids in maintaining security and protecting sensitive data. Security vulnerabilities can be catastrophic, leading to breaches and compromises. Through rigorous testing, potential vulnerabilities can be identified and addressed, fortifying the software against potential cyber threats. - -Testing also supports scalability. It ensures that as the software grows or experiences increased usage, it continues to perform efficiently without compromising speed or functionality. This is particularly crucial in today's tech landscape, where scalability is often a key factor in a software's success. - -In essence, software testing isn't just about finding and fixing bugs. -It's a strategic process that enhances the overall quality, reliability, and security of software, contributing significantly to its success in the market and ensuring a positive user experience. - - - -- cgit v1.2.3