Added argument checks to forbid negative input

This commit is contained in:
Bob Polis 2022-06-11 23:08:39 +02:00
parent 4629c59b45
commit dde62454ea

View File

@ -63,21 +63,25 @@ int main(int argc, char* argv[]) {
case 'u':
valid += upper;
min_upper = std::atoi(optarg);
if (min_upper < 0) throw std::runtime_error("minimum amout of upper case must be zero or more");
noflags = false;
break;
case 'l':
valid += lower;
min_lower = std::atoi(optarg);
if (min_upper < 0) throw std::runtime_error("minimum amout of lower case must be zero or more");
noflags = false;
break;
case 'd':
valid += digits;
min_digits = std::atoi(optarg);
if (min_upper < 0) throw std::runtime_error("minimum amout of digits must be zero or more");
noflags = false;
break;
case 's':
valid += symbols;
min_symbols = std::atoi(optarg);
if (min_upper < 0) throw std::runtime_error("minimum amout of symbols must be zero or more");
noflags = false;
break;
case 'S':