mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Basic tests for HistoryBuf.rewrap
This commit is contained in:
@@ -136,10 +136,14 @@ push(HistoryBuf *self, PyObject *args) {
|
||||
}
|
||||
|
||||
// Boilerplate {{{
|
||||
static PyObject* rewrap(HistoryBuf *self, PyObject *args);
|
||||
#define rewrap_doc ""
|
||||
|
||||
static PyMethodDef methods[] = {
|
||||
METHOD(change_num_of_lines, METH_O)
|
||||
METHOD(line, METH_O)
|
||||
METHOD(push, METH_VARARGS)
|
||||
METHOD(rewrap, METH_VARARGS)
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
@@ -196,4 +200,10 @@ void historybuf_rewrap(HistoryBuf *self, HistoryBuf *other) {
|
||||
if (self->count > 0) rewrap_inner(self, other, self->count, NULL);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
rewrap(HistoryBuf *self, PyObject *args) {
|
||||
HistoryBuf *other;
|
||||
if (!PyArg_ParseTuple(args, "O!", &HistoryBuf_Type, &other)) return NULL;
|
||||
historybuf_rewrap(self, other);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -310,3 +310,21 @@ class TestDataTypes(BaseTest):
|
||||
hb.push(lb.line(2))
|
||||
self.ae(str(hb.line(0)), '2' * hb.xnum)
|
||||
self.ae(str(hb.line(4)), '1' * hb.xnum)
|
||||
|
||||
# rewrap
|
||||
hb = filled_history_buf(5, 5)
|
||||
hb2 = HistoryBuf(hb.ynum, hb.xnum)
|
||||
hb.rewrap(hb2)
|
||||
for i in range(hb.ynum):
|
||||
self.ae(hb2.line(i), hb.line(i))
|
||||
hb2 = HistoryBuf(8, 5)
|
||||
hb.rewrap(hb2)
|
||||
for i in range(hb.ynum):
|
||||
self.ae(hb2.line(i), hb.line(i))
|
||||
for i in range(hb.ynum, hb2.ynum):
|
||||
with self.assertRaises(IndexError):
|
||||
hb2.line(i)
|
||||
hb2 = HistoryBuf(3, 5)
|
||||
hb.rewrap(hb2)
|
||||
for i in range(hb2.ynum):
|
||||
self.ae(hb2.line(i), hb.line(i))
|
||||
|
||||
Reference in New Issue
Block a user