summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <>2024-03-22 13:53:00 +0100
committerOskar <>2024-03-22 13:53:00 +0100
commit6f162676864f6972c302ecab71e44149fa039551 (patch)
treec9c33c0f219be8edaff0075c5a29d14acbd6b026
parent55ac4ebe3bed9b112fa553abece277b309c76bb9 (diff)
vcpm tested, seems OK
-rw-r--r--TODO2
-rw-r--r--i_validation.c7
-rw-r--r--test/testcases/i_validation_cases.txt31
-rw-r--r--test/validate_check_imm.c2
-rw-r--r--test/validate_check_p_m.c7
5 files changed, 47 insertions, 2 deletions
diff --git a/TODO b/TODO
index 3390714..645adc2 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
TODO list. This is mostly so i can plan more granularly and remember small stuff i was working on last time and what i should prioritise first.
This is not my overall big planning board. (1 highest prio, 10 lowest)
-1 - test validate_check_p_m
+1 - test validate_check_p_m (Tested OK)
1 - test validate_check_imm
1 - test validate_plus_continue
1 - testcases for the 3 above
diff --git a/i_validation.c b/i_validation.c
index bc52f9c..a21dd48 100644
--- a/i_validation.c
+++ b/i_validation.c
@@ -19,6 +19,7 @@ _PLUS_CONTINUE (L+ And more numbers after it. Will make validate_plus_continue r
_NA (None of these cases)
*/
char nums[] = "123456789";
+ int iflag = _INVALID;
if (smode_buf[1] == '+' || smode_buf[1] == '-') {
if (smode_buf[2] == '0') {
return _INVALID; // Only L0 (invalid)
@@ -28,10 +29,16 @@ _NA (None of these cases)
}
for (int i = 0 ; i < 9 ; i++) { // Check if theres a number after +
+ iflag = _VALID;
if (smode_buf[2] == nums[i]) {
return _PLUS_CONTINUE; // if true then continue
+ } else {
+ iflag = _INVALID;
}
}
+ if (iflag == _INVALID) {
+ return _INVALID;
+ }
}
return _NA;
diff --git a/test/testcases/i_validation_cases.txt b/test/testcases/i_validation_cases.txt
index 81c8601..83460a2 100644
--- a/test/testcases/i_validation_cases.txt
+++ b/test/testcases/i_validation_cases.txt
@@ -1,16 +1,47 @@
validate_check_p_m
Positive input (Valid):
L+
+L-
+L-1
L+1
+L-2
L+2
+L-3
L+3
+L-9
L+9
+L-10
L+10
L+90
L+100
L+900
+Positive (_NA):
+L0
+L1
+L100
+LL
+Lasd
+L9
+L90
+L900
+
Negative (Invalid):
+L+0
+L-0
+L--
+L++
+L+L
+L-L
+L+asd
+L-asd
+L-0-
+L+0+
+L+0-
+L-0+
+L-0
+
+Overall results: Tested OK. Seems like its working like it should now.
validate_check_imm
Positive input (Valid):
diff --git a/test/validate_check_imm.c b/test/validate_check_imm.c
index b350e68..57c0cdb 100644
--- a/test/validate_check_imm.c
+++ b/test/validate_check_imm.c
@@ -22,7 +22,7 @@ int main () {
printf("?\n");
}
if(ret == _VALID) {
- printf("valid\n");
+ printf("valid plusonly\n");
}
} \ No newline at end of file
diff --git a/test/validate_check_p_m.c b/test/validate_check_p_m.c
index 8809f9a..5a4c135 100644
--- a/test/validate_check_p_m.c
+++ b/test/validate_check_p_m.c
@@ -18,6 +18,13 @@ int main () {
int ret = validate_check_p_m(smode_buf);
+ if(ret == _NA) {
+ printf("NA\n");
+ }
+ if(ret == _PLUS_CONTINUE) {
+ printf("plus continue\n");
+ }
+
if(ret == _INVALID) {
printf("?\n");
}