summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <>2024-03-22 19:56:34 +0100
committerOskar <>2024-03-22 19:56:34 +0100
commit3bb6a5a525bc3edbf853c9f557486fb12081840a (patch)
treeeaf4dece2b6f6c036dbcbd630679bfee1ddcb1b3
parenteb0556f79fec4b7faaa374c702aa78bceb089334 (diff)
vcimm tested, some invalid checks are let through but thats out of scope for this function. It will be checked for in other functions.
-rw-r--r--i_validation.c13
-rw-r--r--i_validation.h2
-rw-r--r--test/testcases/i_validation_cases.txt17
-rw-r--r--test/validate_check_imm.c8
4 files changed, 35 insertions, 5 deletions
diff --git a/i_validation.c b/i_validation.c
index f032131..ffd7c0a 100644
--- a/i_validation.c
+++ b/i_validation.c
@@ -53,6 +53,7 @@ _NA (None of these cases)
_IMM_NUMBER (number immediately after L or N or whatever)
*/
char nums[] = "123456789";
+ int iflag = _INVALID;
if (smode_buf[1] == '\n') {
return _IMM_NOTHING;
@@ -62,9 +63,15 @@ _IMM_NUMBER (number immediately after L or N or whatever)
}
for (int j = 0 ; j < 9 ; j++) { // Check if its just a number after
- if (smode_buf[1] == nums[j]) {
- return _IMM_NUMBER;
- }
+ iflag = _VALID;
+ if (smode_buf[1] == nums[j]) {
+ return _IMM_NUMBER;
+ } else {
+ iflag = _INVALID;
+ }
+ }
+ if (iflag == _INVALID) {
+ return _INVALID;
}
return _NA; // how did we get here?
diff --git a/i_validation.h b/i_validation.h
index 760f857..52525f6 100644
--- a/i_validation.h
+++ b/i_validation.h
@@ -10,7 +10,7 @@
#define _PLUS_CONTINUE 2
#define _PLUS_NOTHING _VALID
#define _IMM_NUMBER 4
-#define _IMM_NOTHING 5
+#define _IMM_NOTHING _VALID
#define _CONTINUE 6
#define _NA 7
diff --git a/test/testcases/i_validation_cases.txt b/test/testcases/i_validation_cases.txt
index 83460a2..4c14ec2 100644
--- a/test/testcases/i_validation_cases.txt
+++ b/test/testcases/i_validation_cases.txt
@@ -45,7 +45,24 @@ Overall results: Tested OK. Seems like its working like it should now.
validate_check_imm
Positive input (Valid):
+L
+L1
+L9
+L10
+L90
+L900
+L100
+
Negative (Invalid):
+LL
+L+
+L+1
+L0
+L+0
+L00
+L0L
+
+Overall results: Tested OK. Seems like its working like it should.
validate_plus_continue
Positive input (Valid):
diff --git a/test/validate_check_imm.c b/test/validate_check_imm.c
index 789cf70..48867f9 100644
--- a/test/validate_check_imm.c
+++ b/test/validate_check_imm.c
@@ -18,11 +18,17 @@ int main () {
int ret = validate_check_imm(smode_buf);
+ if (ret == _IMM_NUMBER) {
+ printf("imm number\n");
+ }
if(ret == _INVALID) {
printf("?\n");
}
if(ret == _VALID) {
- printf("valid plusonly\n");
+ printf("valid\n");
+ }
+ if(ret == _NA) {
+ printf("_NA\n");
}
return 0;