LCOV - code coverage report
Current view: top level - Objects/stringlib - ctype.h (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 41 46 89.1 %
Date: 2022-07-07 18:19:46 Functions: 13 13 100.0 %

          Line data    Source code
       1             : #if STRINGLIB_IS_UNICODE
       2             : # error "ctype.h only compatible with byte-wise strings"
       3             : #endif
       4             : 
       5             : #include "pycore_bytes_methods.h"
       6             : 
       7             : static PyObject*
       8         276 : stringlib_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))
       9             : {
      10         276 :     return _Py_bytes_isspace(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      11             : }
      12             : 
      13             : static PyObject*
      14         274 : stringlib_isalpha(PyObject *self, PyObject *Py_UNUSED(ignored))
      15             : {
      16         274 :     return _Py_bytes_isalpha(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      17             : }
      18             : 
      19             : static PyObject*
      20         276 : stringlib_isalnum(PyObject *self, PyObject *Py_UNUSED(ignored))
      21             : {
      22         276 :     return _Py_bytes_isalnum(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      23             : }
      24             : 
      25             : static PyObject*
      26          76 : stringlib_isascii(PyObject *self, PyObject *Py_UNUSED(ignored))
      27             : {
      28          76 :     return _Py_bytes_isascii(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      29             : }
      30             : 
      31             : static PyObject*
      32         270 : stringlib_isdigit(PyObject *self, PyObject *Py_UNUSED(ignored))
      33             : {
      34         270 :     return _Py_bytes_isdigit(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      35             : }
      36             : 
      37             : static PyObject*
      38         274 : stringlib_islower(PyObject *self, PyObject *Py_UNUSED(ignored))
      39             : {
      40         274 :     return _Py_bytes_islower(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      41             : }
      42             : 
      43             : static PyObject*
      44         274 : stringlib_isupper(PyObject *self, PyObject *Py_UNUSED(ignored))
      45             : {
      46         274 :     return _Py_bytes_isupper(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      47             : }
      48             : 
      49             : static PyObject*
      50          28 : stringlib_istitle(PyObject *self, PyObject *Py_UNUSED(ignored))
      51             : {
      52          28 :     return _Py_bytes_istitle(STRINGLIB_STR(self), STRINGLIB_LEN(self));
      53             : }
      54             : 
      55             : 
      56             : /* functions that return a new object partially translated by ctype funcs: */
      57             : 
      58             : static PyObject*
      59         541 : stringlib_lower(PyObject *self, PyObject *Py_UNUSED(ignored))
      60             : {
      61             :     PyObject* newobj;
      62         541 :     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
      63         541 :     if (!newobj)
      64           0 :             return NULL;
      65         541 :     _Py_bytes_lower(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
      66             :                  STRINGLIB_LEN(self));
      67         541 :     return newobj;
      68             : }
      69             : 
      70             : static PyObject*
      71         291 : stringlib_upper(PyObject *self, PyObject *Py_UNUSED(ignored))
      72             : {
      73             :     PyObject* newobj;
      74         291 :     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
      75         291 :     if (!newobj)
      76           0 :             return NULL;
      77         291 :     _Py_bytes_upper(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
      78             :                  STRINGLIB_LEN(self));
      79         291 :     return newobj;
      80             : }
      81             : 
      82             : static PyObject*
      83          16 : stringlib_title(PyObject *self, PyObject *Py_UNUSED(ignored))
      84             : {
      85             :     PyObject* newobj;
      86          16 :     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
      87          16 :     if (!newobj)
      88           0 :             return NULL;
      89          16 :     _Py_bytes_title(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
      90             :                  STRINGLIB_LEN(self));
      91          16 :     return newobj;
      92             : }
      93             : 
      94             : static PyObject*
      95          14 : stringlib_capitalize(PyObject *self, PyObject *Py_UNUSED(ignored))
      96             : {
      97             :     PyObject* newobj;
      98          14 :     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
      99          14 :     if (!newobj)
     100           0 :             return NULL;
     101          14 :     _Py_bytes_capitalize(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
     102             :                       STRINGLIB_LEN(self));
     103          14 :     return newobj;
     104             : }
     105             : 
     106             : static PyObject*
     107           8 : stringlib_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored))
     108             : {
     109             :     PyObject* newobj;
     110           8 :     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
     111           8 :     if (!newobj)
     112           0 :             return NULL;
     113           8 :     _Py_bytes_swapcase(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
     114             :                     STRINGLIB_LEN(self));
     115           8 :     return newobj;
     116             : }

Generated by: LCOV version 1.14