Yes, I fore warn all candidates that they will do a coding test, with examples of similar tests.
They are allowed to suggest the language they’re most familiar with, they’re told they don’t need to finish and they don’t need to be correct.
It’s just about seeing how they work through something.
If someone like the person you replied to would show up that unprepared , I would really question their own judgement of their abilities.