summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-04-24 16:00:56 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-04-24 16:01:22 +0200
commit46dbd9455c37223932e9427da3c0217f5dcdec41 (patch)
tree0acee3d117fc71821b82f730b9a7f63b3da778c4
parentcc3157c279dea92767a55ff61faaa8d450976c97 (diff)
downloadpygobject-46dbd9455c37223932e9427da3c0217f5dcdec41.tar.gz
Add tests for pyg_constant_strip_prefix()
-rw-r--r--tests/test_internal_api.py9
-rw-r--r--tests/testhelpermodule.c14
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_internal_api.py b/tests/test_internal_api.py
index 9dcde058..090fdc3c 100644
--- a/tests/test_internal_api.py
+++ b/tests/test_internal_api.py
@@ -116,3 +116,12 @@ def test_to_unichar_conv():
with pytest.raises(TypeError):
testhelper.test_to_unichar_conv(u"AA")
+
+
+def test_constant_strip_prefix():
+ assert testhelper.constant_strip_prefix("foo", "bar") == "foo"
+ assert testhelper.constant_strip_prefix("foo", "f") == "oo"
+ assert testhelper.constant_strip_prefix("foo", "f") == "oo"
+ assert testhelper.constant_strip_prefix("ha2foo", "ha") == "a2foo"
+ assert testhelper.constant_strip_prefix("2foo", "ha") == "2foo"
+ assert testhelper.constant_strip_prefix("bla_foo", "bla") == "_foo"
diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c
index 9fc4fc6f..638727b2 100644
--- a/tests/testhelpermodule.c
+++ b/tests/testhelpermodule.c
@@ -526,6 +526,19 @@ _wrap_test_value_array(PyObject *self, PyObject *args)
}
static PyObject *
+_wrap_constant_strip_prefix(PyObject *self, PyObject *args)
+{
+ const char *name, *strip_prefix;
+ const gchar *result;
+
+ if (!PyArg_ParseTuple (args, "ss", &name, &strip_prefix))
+ return NULL;
+
+ result = pyg_constant_strip_prefix (name, strip_prefix);
+ return PYGLIB_PyUnicode_FromString (result);
+}
+
+static PyObject *
_wrap_test_gerror_exception(PyObject *self, PyObject *args)
{
PyObject *py_method;
@@ -642,6 +655,7 @@ static PyMethodDef testhelper_functions[] = {
{ "connectcallbacks", (PyCFunction)_wrap_connectcallbacks, METH_VARARGS },
{ "test_value", (PyCFunction)_wrap_test_value, METH_VARARGS },
{ "test_value_array", (PyCFunction)_wrap_test_value_array, METH_VARARGS },
+ { "constant_strip_prefix", (PyCFunction)_wrap_constant_strip_prefix, METH_VARARGS },
{ "test_gerror_exception", (PyCFunction)_wrap_test_gerror_exception, METH_VARARGS },
{ "owned_by_library_get_instance_list", (PyCFunction)_wrap_test_owned_by_library_get_instance_list, METH_NOARGS },
{ "floating_and_sunk_get_instance_list", (PyCFunction)_wrap_test_floating_and_sunk_get_instance_list, METH_NOARGS },