docstr: Test PyUnicode_WriteChar()
docstr_tok: ["Test","PyUnicode_WriteChar","(",")"]
code: def test_writechar(self):
      """Test PyUnicode_WriteChar()"""
      from _testcapi import unicode_writechar as writechar
  
      strings = [
          # one string for every kind
          "abc",
          "\xa1\xa2\xa3",
          "\u4f60\u597d\u4e16",
          "\U0001f600\U0001f601\U0001f602",
      ]
      # one character for every kind + out of range code
      chars = [0x78, 0xA9, 0x20AC, 0x1F638, 0x110000]
      for i, s in enumerate(strings):
          for j, c in enumerate(chars):
              if j <= i:
                  self.assertEqual(
                      writechar(s, 1, c), (s[:1] + chr(c) + s[2:], 0)
                  )
              else:
                  self.assertRaises(ValueError, writechar, s, 1, c)
  
      self.assertRaises(IndexError, writechar, "abc", 3, 0x78)
      self.assertRaises(IndexError, writechar, "abc", -1, 0x78)
      self.assertRaises(
          IndexError, writechar, "abc", PY_SSIZE_T_MAX, 0x78
      )
      self.assertRaises(
          IndexError, writechar, "abc", PY_SSIZE_T_MIN, 0x78
      )
      self.assertRaises(TypeError, writechar, b"abc", 0, 0x78)
      self.assertRaises(TypeError, writechar, [], 0, 0x78)
  
imports: import unittest
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 3 for calling the CAPITest obj's underlying member method code with example usage: obj.test_writechar() without return types