summaryrefslogtreecommitdiffstatshomepage
path: root/tests/float/string_format.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-08-21 11:56:14 +0100
committerDamien George <damien.p.george@gmail.com>2015-08-21 12:02:09 +0100
commitd007cb890394d9d26c6fafb133532a5175d91eb2 (patch)
tree4fc76a836e7f9738d146bacac9b02f2e288c144b /tests/float/string_format.py
parentd292a81e95bd558f3902f88fa4d6d5641a4aa388 (diff)
downloadmicropython-d007cb890394d9d26c6fafb133532a5175d91eb2.tar.gz
micropython-d007cb890394d9d26c6fafb133532a5175d91eb2.zip
tests: Add more tests to improve coverage, mostly testing exceptions.
Diffstat (limited to 'tests/float/string_format.py')
-rw-r--r--tests/float/string_format.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/float/string_format.py b/tests/float/string_format.py
index 9ffbec4ff7..b605f20978 100644
--- a/tests/float/string_format.py
+++ b/tests/float/string_format.py
@@ -6,12 +6,14 @@ full_tests = False
def test(fmt, *args):
print('{:8s}'.format(fmt) + '>' + fmt.format(*args) + '<')
+test("{:10.4}", 123.456)
test("{:10.4e}", 123.456)
test("{:10.4e}", -123.456)
test("{:10.4f}", 123.456)
test("{:10.4f}", -123.456)
test("{:10.4g}", 123.456)
test("{:10.4g}", -123.456)
+test("{:10.4n}", 123.456)
test("{:e}", 100)
test("{:f}", 200)
test("{:g}", 300)
@@ -128,3 +130,10 @@ else:
# We don't currently test a type of '' with floats (see the detailed comment
# in objstr.c)
+
+# tests for errors in format string
+
+try:
+ '{:10.1b}'.format(0.0)
+except ValueError:
+ print('ValueError')