docstr: Test PyUnicode_AsWideCharString()
docstr_tok: ["Test","PyUnicode_AsWideCharString","(",")"]
code: def test_aswidecharstring(self):
      """Test PyUnicode_AsWideCharString()"""
      from _testcapi import unicode_aswidecharstring
      from _testcapi import unicode_aswidecharstring_null
      from _testcapi import SIZEOF_WCHAR_T
  
      wchar, size = unicode_aswidecharstring("abc")
      self.assertEqual(size, 3)
      self.assertEqual(wchar, "abc\0")
      self.assertEqual(unicode_aswidecharstring_null("abc"), "abc")
  
      wchar, size = unicode_aswidecharstring("abc\0def")
      self.assertEqual(size, 7)
      self.assertEqual(wchar, "abc\0def\0")
      self.assertRaises(
          ValueError, unicode_aswidecharstring_null, "abc\0def"
      )
  
      nonbmp = chr(0x10FFFF)
      if SIZEOF_WCHAR_T == 2:
          nchar = 2
      else:  # SIZEOF_WCHAR_T == 4
          nchar = 1
      wchar, size = unicode_aswidecharstring(nonbmp)
      self.assertEqual(size, nchar)
      self.assertEqual(wchar, nonbmp + "\0")
      self.assertEqual(unicode_aswidecharstring_null(nonbmp), nonbmp)
  
      self.assertRaises(TypeError, unicode_aswidecharstring, b"abc")
      self.assertRaises(TypeError, unicode_aswidecharstring, [])
      self.assertRaises(SystemError, unicode_aswidecharstring, NULL)
      self.assertRaises(
          TypeError, unicode_aswidecharstring_null, b"abc"
      )
      self.assertRaises(TypeError, unicode_aswidecharstring_null, [])
      self.assertRaises(
          SystemError, unicode_aswidecharstring_null, NULL
      )
  
imports: import unittest
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 19 for calling the CAPITest obj's underlying member method code with example usage: obj.test_aswidecharstring() without return types