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