Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS50P: check50 for test_numb3rs (PSET 7) doesn't handle invalid input correctly #312

Open
kcw78 opened this issue Feb 8, 2025 · 1 comment

Comments

@kcw78
Copy link

kcw78 commented Feb 8, 2025

check50 for doesn't handle 4 digit numbers in IPv4 addresses.

This version of test_numb3rs.py results in an error message

def test_IPrange():
    assert validate(r'255.255.255.255') == True
    assert validate(r'1.1.1.1000') == False

Error message is:

:( test_numb3rs.py catches numb3rs.py only checking if first byte of IPv4 address is in range
    expected exit code 1, not 0

Modify test_numb3rs.py as shown below, and the error goes away.

def test_IPrange():
    assert validate(r'255.255.255.255') == True
    assert validate(r'1.1.1.999') == False

Check50 output:
:) test_numb3rs.py catches numb3rs.py only checking if first byte of IPv4 address is in range

@max-min-median
Copy link

Your conclusion is incorrect.
If you ADDED the 999 test instead of CHANGING 1000 to 999, I believe there would also be no error.
That indicates that it is not a problem of check50 not handling the 1000 test, but rather that you did not have another test which would expose the flaw in the code.
Note that 1000 could possibly be picked up as false for having too many digits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants