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

New test case for Phone Number exercise #2434

Closed
Aryan570 opened this issue May 3, 2024 · 1 comment
Closed

New test case for Phone Number exercise #2434

Aryan570 opened this issue May 3, 2024 · 1 comment

Comments

@Aryan570
Copy link

Aryan570 commented May 3, 2024

A case like - "223.456abc.7890" should be added to tests cause a code like mine (in Rust) can easily pass the tests -

    let mut v = vec![' ';10];
    let mut tmp = 9;
    for ch in user_number.chars().rev(){
        match ch {
             c @ '0'..='9' =>{
                if (tmp == -1 && c != '1') 
                || (tmp == 0 && c == '1') 
                || (tmp == 0 && c == '0')
                || (tmp == 3 && c == '0')
                || (tmp == 3 && c == '1'){
                    return None;
                }
                if tmp >=0 {
                    v[tmp as usize] = c;
                }
                tmp -= 1;
            }
            _ => continue,
        }
    }
    if v[0] == ' '{return None;}
    Some(v.iter().collect())
}

test like this should be added (the code above will treat it as a valid number, but it isn't valid) -

fn invalid_chars() {
    let input = "223.456abc.7890";
    let output = number(input);
    assert!(output.is_none());
}
Copy link
Contributor

github-actions bot commented May 3, 2024

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

@github-actions github-actions bot closed this as completed May 3, 2024
@Aryan570 Aryan570 changed the title new test case for Phone Number New test case for Phone Number exercise May 3, 2024
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

1 participant