Any standard test framework would be able to do this, it's just a string comparison.
For quiz questions, it's likely that the person that set the exam wrote a correct solution and used that to generate test data, or used it directly in the assertions.
If you were doing this kind of question...