From 6bc937cfd2c7265e00d3838485fcc99a655b8aa7 Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Fri, 24 Sep 2004 19:18:42 +0000 Subject: [PATCH] Add yet more tests for buffer(). --- Lib/test/test_types.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index d0d06359af0..2dd3b88bf4f 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -253,6 +253,17 @@ if str(buffer(a, 0, 2)) != 'as': raise TestFailed, 'specifying buffer size failed' if str(buffer(a, 1, 2)) != 'sd': raise TestFailed, 'specifying buffer offset and size failed' +try: buffer(buffer('asdf', 1), -1) +except ValueError: pass +else: raise TestFailed, "buffer(buffer('asdf', 1), -1) should raise ValueError" +if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' +if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' +if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' +if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': + raise TestFailed, 'composing length-specified buffer failed' try: a[1] = 'g' except TypeError: pass