Guido van Rossum | 28d4ba2 | 1996-09-11 19:07:45 +0000 | [diff] [blame] | 1 | import strop, sys |
| 2 | |
| 3 | def test(name, input, output): |
| 4 | f = getattr(strop, name) |
| 5 | try: |
| 6 | value = f(input) |
| 7 | except: |
| 8 | value = sys.exc_type |
Guido van Rossum | 28d4ba2 | 1996-09-11 19:07:45 +0000 | [diff] [blame] | 9 | if value != output: |
| 10 | print f, `input`, `output`, `value` |
| 11 | |
| 12 | test('atoi', " 1 ", 1) |
| 13 | test('atoi', " 1x", ValueError) |
| 14 | test('atoi', " x1 ", ValueError) |
| 15 | test('atol', " 1 ", 1L) |
| 16 | test('atol', " 1x ", ValueError) |
| 17 | test('atol', " x1 ", ValueError) |
| 18 | test('atof', " 1 ", 1.0) |
| 19 | test('atof', " 1x ", ValueError) |
| 20 | test('atof', " x1 ", ValueError) |