A
A
Alex Bro2020-09-28 15:07:08
iOS
Alex Bro, 2020-09-28 15:07:08

How to write unit tests for the login verification function (swift)?

I have a login validation function, what should unit tests look like for it?

func isAllowed(withLogin login: String?) -> Bool {
        let regex: String = "^((?!([0-9/./-]))[a-zA-Z0-9/@/./-]{3,32})$"
        let predicate = NSPredicate(format: "SELF MATCHES %@", regex)

        return predicate.evaluate(with: login)
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Cherny, 2020-09-28
@freeg0r

Here is an example with a set of valid/invalid emails: https://codefool.tumblr.com/post/15288874550/list-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question