code: def test_single_char_arguments():
      """Tests failures for passing invalid inputs to char-accepting functions"""
      from pybind11_tests import (
          ord_char,
          ord_char16,
          ord_char32,
          ord_wchar,
          wchar_size,
      )
  
      def toobig_message(r):
          return "Character code point not in range({0:#x})".format(r)
  
      toolong_message = (
          "Expected a character, but multi-character string found"
      )
  
      assert ord_char("a") == 0x61  # simple ASCII
      assert (
          ord_char("é") == 0xE9
      )  # requires 2 bytes in utf-8, but can be stuffed in a char
      with pytest.raises(ValueError) as excinfo:
          assert (
              ord_char("Ā") == 0x100
          )  # requires 2 bytes, doesn't fit in a char
      assert str(excinfo.value) == toobig_message(0x100)
      with pytest.raises(ValueError) as excinfo:
          assert ord_char("ab")
      assert str(excinfo.value) == toolong_message
  
      assert ord_char16("a") == 0x61
      assert ord_char16("é") == 0xE9
      assert ord_char16("Ā") == 0x100
      assert ord_char16("‽") == 0x203D
      assert ord_char16("♥") == 0x2665
      with pytest.raises(ValueError) as excinfo:
          assert ord_char16("🎂") == 0x1F382  # requires surrogate pair
      assert str(excinfo.value) == toobig_message(0x10000)
      with pytest.raises(ValueError) as excinfo:
          assert ord_char16("aa")
      assert str(excinfo.value) == toolong_message
  
      assert ord_char32("a") == 0x61
      assert ord_char32("é") == 0xE9
      assert ord_char32("Ā") == 0x100
      assert ord_char32("‽") == 0x203D
      assert ord_char32("♥") == 0x2665
      assert ord_char32("🎂") == 0x1F382
      with pytest.raises(ValueError) as excinfo:
          assert ord_char32("aa")
      assert str(excinfo.value) == toolong_message
  
      assert ord_wchar("a") == 0x61
      assert ord_wchar("é") == 0xE9
      assert ord_wchar("Ā") == 0x100
      assert ord_wchar("‽") == 0x203D
      assert ord_wchar("♥") == 0x2665
      if wchar_size == 2:
          with pytest.raises(ValueError) as excinfo:
              assert (
                  ord_wchar("🎂") == 0x1F382
              )  # requires surrogate pair
          assert str(excinfo.value) == toobig_message(0x10000)
      else:
          assert ord_wchar("🎂") == 0x1F382
      with pytest.raises(ValueError) as excinfo:
          assert ord_wchar("aa")
      assert str(excinfo.value) == toolong_message
  
file_path: coremltools/deps/pybind11/tests/test_python_types.py
imports: import pytest
  from pybind11_tests import ExamplePythonTypes, ConstructorStats, has_optional, has_exp_optional
label_desc: Use image node_id 17 for calling a global function with example usage: test_single_char_arguments() and returns: str