docstr: Test PyUnicode_DecodeUTF32Stateful()
docstr_tok: ["Test","PyUnicode_DecodeUTF32Stateful","(",")"]
code: def test_decodeutf32stateful(self):
      """Test PyUnicode_DecodeUTF32Stateful()"""
      decodeutf32stateful = _testcapi.unicode_decodeutf32stateful
  
      naturalbyteorder = -1 if sys.byteorder == "little" else 1
      for s in ["abc", "\xa1\xa2", "\u4f60\u597d", "a\U0001f600"]:
          b = s.encode("utf-32")
          self.assertEqual(
              decodeutf32stateful(0, b), (naturalbyteorder, s, len(b))
          )
          b = s.encode("utf-32le")
          self.assertEqual(decodeutf32stateful(-1, b), (-1, s, len(b)))
          self.assertEqual(
              decodeutf32stateful(0, b"\xff\xfe\x00\x00" + b),
              (-1, s, len(b) + 4),
          )
          b = s.encode("utf-32be")
          self.assertEqual(decodeutf32stateful(1, b), (1, s, len(b)))
          self.assertEqual(
              decodeutf32stateful(0, b"\x00\x00\xfe\xff" + b),
              (1, s, len(b) + 4),
          )
  
      self.assertEqual(
          decodeutf32stateful(-1, b"\x61\x00\x00\x00\x00"), (-1, "a", 4)
      )
      self.assertEqual(
          decodeutf32stateful(-1, b"\x61\x00\x00\x00\x00\xf6"),
          (-1, "a", 4),
      )
      self.assertEqual(
          decodeutf32stateful(-1, b"\x61\x00\x00\x00\x00\xf6\x01"),
          (-1, "a", 4),
      )
      self.assertEqual(
          decodeutf32stateful(1, b"\x00\x00\x00\x61\x00"), (1, "a", 4)
      )
      self.assertEqual(
          decodeutf32stateful(1, b"\x00\x00\x00\x61\x00\x01"),
          (1, "a", 4),
      )
      self.assertEqual(
          decodeutf32stateful(1, b"\x00\x00\x00\x61\x00\x01\xf6"),
          (1, "a", 4),
      )
      self.assertEqual(
          decodeutf32stateful(
              0, b"\xff\xfe\x00\x00\x61\x00\x00\x00\x00\xf6\x01"
          ),
          (-1, "a", 8),
      )
      self.assertEqual(
          decodeutf32stateful(
              0, b"\x00\x00\xfe\xff\x00\x00\x00\x61\x00\x01\xf6"
          ),
          (1, "a", 8),
      )
  
      for b in b"\xff", b"\xff\xff", b"\xff\xff\xff":
          self.assertEqual(decodeutf32stateful(-1, b), (-1, "", 0))
          self.assertEqual(decodeutf32stateful(1, b), (1, "", 0))
          self.assertEqual(decodeutf32stateful(0, b), (0, "", 0))
          self.assertEqual(
              decodeutf32stateful(0, b"\xff\xfe\x00\x00" + b),
              (-1, "", 4),
          )
          self.assertEqual(
              decodeutf32stateful(0, b"\x00\x00\xfe\xff" + b),
              (1, "", 4),
          )
      self.assertRaises(
          UnicodeDecodeError,
          decodeutf32stateful,
          -1,
          b"\xff\xff\xff\xff",
      )
      self.assertRaises(
          UnicodeDecodeError,
          decodeutf32stateful,
          1,
          b"\xff\xff\xff\xff",
      )
      self.assertRaises(
          UnicodeDecodeError,
          decodeutf32stateful,
          0,
          b"\xff\xff\xff\xff",
      )
      self.assertEqual(
          decodeutf32stateful(-1, b"\xff\xff\xff\xff", "replace"),
          (-1, "\ufffd", 4),
      )
      self.assertEqual(
          decodeutf32stateful(1, b"\xff\xff\xff\xff", "replace"),
          (1, "\ufffd", 4),
      )
      self.assertEqual(
          decodeutf32stateful(0, b"\xff\xff\xff\xff", "replace"),
          (0, "\ufffd", 4),
      )
      self.assertEqual(
          decodeutf32stateful(
              0, b"\xff\xfe\x00\x00\xff\xff\xff\xff", "replace"
          ),
          (-1, "\ufffd", 8),
      )
      self.assertEqual(
          decodeutf32stateful(
              0, b"\x00\x00\xfe\xff\xff\xff\xff\xff", "replace"
          ),
          (1, "\ufffd", 8),
      )
  
      self.assertRaises(
          UnicodeDecodeError,
          decodeutf32stateful,
          -1,
          b"\x3d\xd8\x00\x00",
      )
      self.assertEqual(
          decodeutf32stateful(-1, b"\x3d\xd8\x00\x00", "replace"),
          (-1, "\ufffd", 4),
      )
      self.assertRaises(
          UnicodeDecodeError,
          decodeutf32stateful,
          1,
          b"\x00\x00\xd8\x3d",
      )
      self.assertEqual(
          decodeutf32stateful(1, b"\x00\x00\xd8\x3d", "replace"),
          (1, "\ufffd", 4),
      )
  
      self.assertRaises(
          LookupError,
          decodeutf32stateful,
          -1,
          b"\xff\xff\xff\xff",
          "foo",
      )
      self.assertRaises(
          LookupError,
          decodeutf32stateful,
          1,
          b"\xff\xff\xff\xff",
          "foo",
      )
      self.assertRaises(
          LookupError,
          decodeutf32stateful,
          0,
          b"\xff\xff\xff\xff",
          "foo",
      )
  
imports: import unittest
  import sys
  from test.support import import_helper
label_desc: Use image node_id 11 for calling the CAPITest obj's underlying member method code with example usage: obj.test_decodeutf32stateful() without return types