Pergunta de entrevista da empresa Multivision

How do you test if a string is valid in date format?

Resposta da entrevista

Sigiloso

14 de jul. de 2015

Suppose the date format is like yyyy-mm-dd. Then write following test code to judge if the condition is satisfied. 1. Test if the length of this string is correct. 2. Test if first 4 characters are numbers. 3. Test if month is correct. 4. Test if date is correct. If any of the above fails, return false. If all pass, return true.