[pygobject] Add tests for pyg_constant_strip_prefix()
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Add tests for pyg_constant_strip_prefix()
- Date: Tue, 24 Apr 2018 14:13:18 +0000 (UTC)
commit 46dbd9455c37223932e9427da3c0217f5dcdec41
Author: Christoph Reiter <reiter christoph gmail com>
Date: Tue Apr 24 16:00:56 2018 +0200
Add tests for pyg_constant_strip_prefix()
tests/test_internal_api.py | 9 +++++++++
tests/testhelpermodule.c | 14 ++++++++++++++
2 files changed, 23 insertions(+)
---
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
@@ -525,6 +525,19 @@ _wrap_test_value_array(PyObject *self, PyObject *args)
return pyg_value_as_pyobject(value, FALSE);
}
+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)
{
@@ -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 },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]