docstr: Test PyUnicode_AsUTF8AndSize()
docstr_tok: ["Test","PyUnicode_AsUTF8AndSize","(",")"]
code: def test_asutf8andsize(self):
      """Test PyUnicode_AsUTF8AndSize()"""
      from _testcapi import unicode_asutf8andsize
      from _testcapi import unicode_asutf8andsize_null
  
      self.assertEqual(unicode_asutf8andsize("abc", 4), (b"abc\0", 3))
      self.assertEqual(
          unicode_asutf8andsize("абв", 7),
          (b"\xd0\xb0\xd0\xb1\xd0\xb2\0", 6),
      )
      self.assertEqual(
          unicode_asutf8andsize("\U0001f600", 5),
          (b"\xf0\x9f\x98\x80\0", 4),
      )
      self.assertEqual(
          unicode_asutf8andsize("abc\0def", 8), (b"abc\0def\0", 7)
      )
      self.assertEqual(unicode_asutf8andsize_null("abc", 4), b"abc\0")
      self.assertEqual(
          unicode_asutf8andsize_null("abc\0def", 8), b"abc\0def\0"
      )
  
      self.assertRaises(
          UnicodeEncodeError, unicode_asutf8andsize, "\ud8ff", 0
      )
      self.assertRaises(TypeError, unicode_asutf8andsize, b"abc", 0)
      self.assertRaises(TypeError, unicode_asutf8andsize, [], 0)
      self.assertRaises(
          UnicodeEncodeError, unicode_asutf8andsize_null, "\ud8ff", 0
      )
      self.assertRaises(
          TypeError, unicode_asutf8andsize_null, b"abc", 0
      )
      self.assertRaises(TypeError, unicode_asutf8andsize_null, [], 0)
  
imports: import unittest
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 24 for calling the CAPITest obj's underlying member method code with example usage: obj.test_asutf8andsize() without return types