Test for LineBuf.clear()
Also raise IndexError instead of ValueError for line and char access
This commit is contained in:
parent
d874155f1e
commit
b12af6f21d
@ -95,7 +95,7 @@ line(LineBuf *self, PyObject *y) {
|
||||
#define line_doc "Return the specified line as a Line object. Note the Line Object is a live view into the underlying buffer. And only a single line object can be used at a time."
|
||||
unsigned long idx = PyLong_AsUnsignedLong(y);
|
||||
if (idx >= self->ynum) {
|
||||
PyErr_SetString(PyExc_ValueError, "Line number too large");
|
||||
PyErr_SetString(PyExc_IndexError, "Line number too large");
|
||||
return NULL;
|
||||
}
|
||||
self->line->ynum = idx;
|
||||
|
||||
@ -126,6 +126,12 @@ class TestDataTypes(BaseTest):
|
||||
self.ae(str(l), '0 00')
|
||||
self.assertEqualAttributes(l.cursor_from(1), l.cursor_from(0))
|
||||
|
||||
lb = filled_line_buf(10, 10, filled_cursor())
|
||||
lb.clear()
|
||||
lb2 = LineBuf(lb.ynum, lb.ynum)
|
||||
for i in range(lb.ynum):
|
||||
self.ae(lb.line(i), lb2.line(i))
|
||||
|
||||
def test_line(self):
|
||||
lb = LineBuf(2, 3)
|
||||
for y in range(lb.ynum):
|
||||
@ -133,9 +139,9 @@ class TestDataTypes(BaseTest):
|
||||
self.ae(str(line), ' ' * lb.xnum)
|
||||
for x in range(lb.xnum):
|
||||
self.ae(line[x], ' ')
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(IndexError):
|
||||
lb.line(lb.ynum)
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(IndexError):
|
||||
lb.line(0)[lb.xnum]
|
||||
l = lb.line(0)
|
||||
l.add_combining_char(0, '1')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user