docstr: Test PyUnicode_Substring()
docstr_tok: ["Test","PyUnicode_Substring","(",")"]
code: def test_substring(self):
      """Test PyUnicode_Substring()"""
      from _testcapi import unicode_substring as substring
  
      strings = [
          "ab",
          "ab\xa1\xa2",
          "ab\xa1\xa2\u4f60\u597d",
          "ab\xa1\xa2\u4f60\u597d\U0001f600\U0001f601",
      ]
      for s in strings:
          for start in [*range(0, len(s) + 2), PY_SSIZE_T_MAX]:
              for end in [
                  *range(max(start - 1, 0), len(s) + 2),
                  PY_SSIZE_T_MAX,
              ]:
                  self.assertEqual(
                      substring(s, start, end), s[start:end]
                  )
  
      self.assertRaises(IndexError, substring, "abc", -1, 0)
      self.assertRaises(IndexError, substring, "abc", PY_SSIZE_T_MIN, 0)
      self.assertRaises(IndexError, substring, "abc", 0, -1)
      self.assertRaises(IndexError, substring, "abc", 0, PY_SSIZE_T_MIN)
  
imports: import unittest
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 10 for calling the CAPITest obj's underlying member method code with example usage: obj.test_substring() without return types