Hacker News new | ask | show | jobs
by sharemywin 1215 days ago
Actually, it probably could write really good test cases. they tend to be boring and verbose.

It's only test data but you get the point

Sure, here are some examples of phone numbers in various formats:

(123) 456-7890 123-456-7890 +1 (123) 456-7890 1-800-123-4567 555.123.4567 123.456.7890 1234567890 (123) 456-7890 ext. 123 +44 123 456 7890 (international format) 011 44 123 456 7890 (international access code format) 123/456-7890 123\456-7890 (123) 456-7890 x1234 (with extension) 123-456-7890 x1234 (with extension) 1 (123) 456-7890 (with country code)

3 comments

I use Copilot to write my tests, but using ChatGPT to generate test data could be a good idea. I'll have to fiddle with it when i'm not on a timer.

Thank you for the suggestion.

Out of curiosity I tried chat GPT for this and it was able to generate a reasonable set of test cases but only after prompting it for including international access and "+" characters. I also had to prompt it to use the parameterize feature, but I guess that's personal preference.

Final test: https://pastebin.com/J36JY78i

First response: https://pastebin.com/S23GFPDq

All great test cases. Here are a few more test cases for valid phone numbers:

0893514656, 089 3514656, +49893514656, 08921610, 089 2 16 10, 08992949451 ...