code: def test_functions(self):
      strchr = lib.my_strchr
      strchr.restype = c_char_p
  
      # c_char_p and Python string is compatible
      # c_char_p and create_string_buffer are now compatible
      strchr.argtypes = c_char_p, c_char
      self.assertEqual(strchr(b"abcdef", b"c"), b"cdef")
      self.assertEqual(
          strchr(create_string_buffer(b"abcdef"), b"c"), b"cdef"
      )
  
      # POINTER(c_char) and Python string is NOT compatible
      # POINTER(c_char) and create_string_buffer() is compatible
      strchr.argtypes = POINTER(c_char), c_char
      buf = create_string_buffer(b"abcdef")
      self.assertEqual(strchr(buf, b"c"), b"cdef")
      self.assertEqual(strchr(b"abcdef", b"c"), b"cdef")
  
      # XXX These calls are dangerous, because the first argument
      # to strchr is no longer valid after the function returns!
      # So we must keep a reference to buf separately
  
      strchr.restype = POINTER(c_char)
      buf = create_string_buffer(b"abcdef")
      r = strchr(buf, b"c")
      x = r[0], r[1], r[2], r[3], r[4]
      self.assertEqual(x, (b"c", b"d", b"e", b"f", b"\000"))
      del buf
  
file_path: cpython/Lib/test/test_ctypes/test_stringptr.py
imports: import _ctypes_test
  import sys
  import unittest
  from test import support
  from ctypes import CDLL, Structure, POINTER, create_string_buffer, c_char, c_char_p
label_desc: Use image node_id 3 for calling the StringPtrTestCase obj's underlying member method code with example usage: obj.test_functions() without return types