diff options
author | Oskar <[email protected]> | 2024-02-18 18:42:40 +0100 |
---|---|---|
committer | Oskar <[email protected]> | 2024-02-18 18:42:40 +0100 |
commit | fc966f297cc163254220c930a565484abde207d9 (patch) | |
tree | 554a1b9c13ed7aaadf4cfe32525d110ee9ab78c6 | |
parent | 02baef3cfdfec7705b44c1a56c8e1a291df92f39 (diff) |
Organised test directory and did some logic fixes to smode
-rw-r--r-- | input.c | 15 | ||||
-rw-r--r-- | test/smode | bin | 25488 -> 0 bytes | |||
-rw-r--r-- | test/testcases/smode_cases.txt | 16 | ||||
-rw-r--r-- | test/testgrounds/endnewlinetest (renamed from test/endnewlinetest) | 0 | ||||
-rw-r--r-- | test/testgrounds/file.txt (renamed from test/file.txt) | 0 | ||||
-rw-r--r-- | test/testgrounds/file2.txt (renamed from test/file2.txt) | 0 | ||||
-rw-r--r-- | test/testgrounds/newlinetest (renamed from test/newlinetest) | 0 | ||||
-rw-r--r-- | test/testgrounds/newlinetest2 (renamed from test/newlinetest2) | 0 | ||||
-rw-r--r-- | test/testgrounds/noline (renamed from test/noline) | 0 | ||||
-rw-r--r-- | test/testgrounds/testgetline.c (renamed from test/testgetline.c) | 0 | ||||
-rw-r--r-- | test/testgrounds/text_about_testing.txt (renamed from test/text_about_testing.txt) | 0 |
11 files changed, 31 insertions, 0 deletions
@@ -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/smode b/test/smode Binary files differdeleted file mode 100644 index 16fc213..0000000 --- a/test/smode +++ /dev/null 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/endnewlinetest b/test/testgrounds/endnewlinetest index 1727e1a..1727e1a 100644 --- a/test/endnewlinetest +++ b/test/testgrounds/endnewlinetest diff --git a/test/file.txt b/test/testgrounds/file.txt index 6f741aa..6f741aa 100644 --- a/test/file.txt +++ b/test/testgrounds/file.txt diff --git a/test/file2.txt b/test/testgrounds/file2.txt index 73ee54a..73ee54a 100644 --- a/test/file2.txt +++ b/test/testgrounds/file2.txt diff --git a/test/newlinetest b/test/testgrounds/newlinetest index f00c965..f00c965 100644 --- a/test/newlinetest +++ b/test/testgrounds/newlinetest diff --git a/test/newlinetest2 b/test/testgrounds/newlinetest2 index f00c965..f00c965 100644 --- a/test/newlinetest2 +++ b/test/testgrounds/newlinetest2 diff --git a/test/noline b/test/testgrounds/noline index 08a1db1..08a1db1 100644 --- a/test/noline +++ b/test/testgrounds/noline diff --git a/test/testgetline.c b/test/testgrounds/testgetline.c index d186439..d186439 100644 --- a/test/testgetline.c +++ b/test/testgrounds/testgetline.c diff --git a/test/text_about_testing.txt b/test/testgrounds/text_about_testing.txt index 4857dfb..4857dfb 100644 --- a/test/text_about_testing.txt +++ b/test/testgrounds/text_about_testing.txt |