code: def test_hash_pointer(self):
      # Test Py_HashPointer()
      hash_pointer = _testcapi.hash_pointer
  
      UHASH_T_MASK = (2 ** (8 * SIZEOF_PY_HASH_T)) - 1
      HASH_T_MAX = 2 ** (8 * SIZEOF_PY_HASH_T - 1) - 1
  
      def python_hash_pointer(x):
          # Py_HashPointer() rotates the pointer bits by 4 bits to the right
          x = (x >> 4) | ((x & 15) << (8 * SIZEOF_VOID_P - 4))
  
          # Convert unsigned uintptr_t (Py_uhash_t) to signed Py_hash_t
          if HASH_T_MAX < x:
              x = (~x) + 1
              x &= UHASH_T_MASK
              x = (~x) + 1
          return x
  
      if SIZEOF_VOID_P == 8:
          values = (
              0xABCDEF1234567890,
              0x1234567890ABCDEF,
              0xFEE4ABEDD1CECA5E,
          )
      else:
          values = (
              0x12345678,
              0x1234ABCD,
              0xDEADCAFE,
          )
  
      for value in values:
          expected = python_hash_pointer(value)
          with self.subTest(value=value):
              self.assertEqual(
                  hash_pointer(value),
                  expected,
                  f"hash_pointer({value:x}) = "
                  f"{hash_pointer(value):x} != {expected:x}",
              )
  
      # Py_HashPointer(NULL) returns 0
      self.assertEqual(hash_pointer(0), 0)
  
      # Py_HashPointer((void*)(uintptr_t)-1) doesn't return -1 but -2
      VOID_P_MAX = -1 & (2 ** (8 * SIZEOF_VOID_P) - 1)
      self.assertEqual(hash_pointer(VOID_P_MAX), -2)
  
imports: import sys
  import unittest
  from test.support import import_helper
label_desc: Use image node_id 2 for calling the CAPITest obj's underlying member method code with example usage: obj.test_hash_pointer() and returns: x