code: def test_check_surface(rng):
      coords, faces = generate_surf()
      mesh = Mesh(coords, faces)
      data = mesh[0][:, 0]
      surf = Surface(mesh, data)
      s = surface.check_surface(surf)
      assert_array_equal(s.data, data)
      assert_array_equal(s.data, surf.data)
      assert_array_equal(s.mesh.coordinates, coords)
      assert_array_equal(s.mesh.coordinates, mesh.coordinates)
      assert_array_equal(s.mesh.faces, faces)
      assert_array_equal(s.mesh.faces, mesh.faces)
      # Generate faces such that max index is larger than
      # the length of coordinates array.
      wrong_faces = rng.integers(coords.shape[0] + 1, size=(30, 3))
      wrong_mesh = Mesh(coords, wrong_faces)
      wrong_surface = Surface(wrong_mesh, data)
      # Check that check_mesh_and_data raises an error
      # with the resulting wrong mesh
      with pytest.raises(
          ValueError,
          match="Mismatch between .* indices of faces .* number of nodes.",
      ):
          surface.check_surface(wrong_surface)
      # Alter the data and check that an error is raised
      wrong_data = mesh[0][::2, 0]
      wrong_surface = Surface(mesh, wrong_data)
      with pytest.raises(
          ValueError, match="Mismatch between number of nodes in mesh"
      ):
          surface.check_surface(wrong_surface)
  
imports: import os
  import tempfile
  import warnings
  import nibabel
  import numpy
  import pytest
  from nibabel import gifti
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from scipy.spatial import Delaunay
  from scipy.stats import pearsonr
  from nilearn import datasets, image
  from nilearn._utils import data_gen
  from nilearn.image import resampling
  from nilearn.surface import Mesh, Surface, load_surf_data, load_surf_mesh, surface
  from nilearn.surface.surface import _gifti_img_to_mesh, _load_surf_files_gifti_gzip
  from nilearn.surface.tests._testing import flat_mesh, generate_surf, z_const_img
label_desc: Use image node_id 34 for calling a global function with example usage: test_check_surface(rng) without return types