docstr: Test PyUnicode_DecodeUTF16()
docstr_tok: ["Test","PyUnicode_DecodeUTF16","(",")"]
code: def test_decodeutf16(self):
      """Test PyUnicode_DecodeUTF16()"""
      decodeutf16 = _testcapi.unicode_decodeutf16
  
      naturalbyteorder = -1 if sys.byteorder == "little" else 1
      for s in ["abc", "\xa1\xa2", "\u4f60\u597d", "a\U0001f600"]:
          b = s.encode("utf-16")
          self.assertEqual(decodeutf16(0, b), (naturalbyteorder, s))
          b = s.encode("utf-16le")
          self.assertEqual(decodeutf16(-1, b), (-1, s))
          self.assertEqual(decodeutf16(0, b"\xff\xfe" + b), (-1, s))
          b = s.encode("utf-16be")
          self.assertEqual(decodeutf16(1, b), (1, s))
          self.assertEqual(decodeutf16(0, b"\xfe\xff" + b), (1, s))
  
      self.assertRaises(UnicodeDecodeError, decodeutf16, -1, b"a")
      self.assertRaises(UnicodeDecodeError, decodeutf16, 1, b"a")
      self.assertRaises(
          UnicodeDecodeError, decodeutf16, 0, b"\xff\xfea"
      )
      self.assertRaises(
          UnicodeDecodeError, decodeutf16, 0, b"\xfe\xffa"
      )
  
      self.assertRaises(
          UnicodeDecodeError, decodeutf16, -1, b"\x00\xde"
      )
      self.assertRaises(UnicodeDecodeError, decodeutf16, 1, b"\xde\x00")
      self.assertRaises(UnicodeDecodeError, decodeutf16, 0, b"\xde\xde")
      self.assertEqual(
          decodeutf16(-1, b"\x00\xde", "replace"), (-1, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(1, b"\xde\x00", "replace"), (1, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(0, b"\xde\xde", "replace"), (0, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(0, b"\xff\xfe\x00\xde", "replace"), (-1, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(0, b"\xfe\xff\xde\x00", "replace"), (1, "\ufffd")
      )
  
      self.assertRaises(
          UnicodeDecodeError, decodeutf16, -1, b"\x3d\xd8"
      )
      self.assertRaises(UnicodeDecodeError, decodeutf16, 1, b"\xd8\x3d")
      self.assertRaises(UnicodeDecodeError, decodeutf16, 0, b"\xd8\xd8")
      self.assertEqual(
          decodeutf16(-1, b"\x3d\xd8", "replace"), (-1, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(1, b"\xd8\x3d", "replace"), (1, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(0, b"\xd8\xd8", "replace"), (0, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(0, b"\xff\xfe\x3d\xd8", "replace"), (-1, "\ufffd")
      )
      self.assertEqual(
          decodeutf16(0, b"\xfe\xff\xd8\x3d", "replace"), (1, "\ufffd")
      )
  
      self.assertRaises(
          LookupError, decodeutf16, -1, b"\x00\xde", "foo"
      )
      self.assertRaises(LookupError, decodeutf16, 1, b"\xde\x00", "foo")
      self.assertRaises(LookupError, decodeutf16, 0, b"\xde\xde", "foo")
  
imports: import unittest
  import sys
  from test.support import import_helper
label_desc: Use image node_id 7 for calling the CAPITest obj's underlying member method code with example usage: obj.test_decodeutf16() without return types