docstr: Test PyUnicode_Find()
docstr_tok: ["Test","PyUnicode_Find","(",")"]
code: def test_find(self):
      """Test PyUnicode_Find()"""
      from _testcapi import unicode_find as find
  
      for str in (
          "\xa1",
          "\u8000\u8080",
          "\ud800\udc02",
          "\U0001f100\U0001f1f1",
      ):
          for i, ch in enumerate(str):
              self.assertEqual(find(str, ch, 0, len(str), 1), i)
              self.assertEqual(find(str, ch, 0, len(str), -1), i)
  
      str = "!>_<!"
      self.assertEqual(find(str, "z", 0, len(str), 1), -1)
      self.assertEqual(find(str, "z", 0, len(str), -1), -1)
      self.assertEqual(find(str, "", 0, len(str), 1), 0)
      self.assertEqual(find(str, "", 0, len(str), -1), len(str))
      # start < end
      self.assertEqual(find(str, "!", 1, len(str) + 1, 1), 4)
      self.assertEqual(find(str, "!", 1, PY_SSIZE_T_MAX, 1), 4)
      self.assertEqual(find(str, "!", 0, len(str) + 1, -1), 4)
      self.assertEqual(find(str, "!", 0, PY_SSIZE_T_MAX, -1), 4)
      # start >= end
      self.assertEqual(find(str, "!", 0, 0, 1), -1)
      self.assertEqual(find(str, "!", 0, 0, -1), -1)
      self.assertEqual(find(str, "!", len(str), 0, 1), -1)
      self.assertEqual(find(str, "!", len(str), 0, -1), -1)
      # negative
      self.assertEqual(find(str, "!", -len(str), -1, 1), 0)
      self.assertEqual(find(str, "!", -len(str), -1, -1), 0)
      self.assertEqual(find(str, "!", PY_SSIZE_T_MIN, -1, 1), 0)
      self.assertEqual(find(str, "!", PY_SSIZE_T_MIN, -1, -1), 0)
      self.assertEqual(
          find(str, "!", PY_SSIZE_T_MIN, PY_SSIZE_T_MAX, 1), 0
      )
      self.assertEqual(
          find(str, "!", PY_SSIZE_T_MIN, PY_SSIZE_T_MAX, -1), 4
      )
      # bad arguments
      self.assertRaises(TypeError, find, str, b"!", 0, len(str), 1)
      self.assertRaises(TypeError, find, b"!>_<!", "!", 0, len(str), 1)
      self.assertRaises(TypeError, find, str, ord("!"), 0, len(str), 1)
      self.assertRaises(TypeError, find, [], "!", 0, len(str), 1)
  
imports: import unittest
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 37 for calling the CAPITest obj's underlying member method code with example usage: obj.test_find() without return types