test_string.py 610 B

12345678910111213141516171819202122
  1. import os
  2. import pytest
  3. from numpy.testing import assert_array_equal
  4. import numpy as np
  5. from . import util
  6. def _path(*a):
  7. return os.path.join(*((os.path.dirname(__file__),) + a))
  8. class TestString(util.F2PyTest):
  9. sources = [_path('src', 'string', 'char.f90')]
  10. @pytest.mark.slow
  11. def test_char(self):
  12. strings = np.array(['ab', 'cd', 'ef'], dtype='c').T
  13. inp, out = self.module.char_test.change_strings(strings, strings.shape[1])
  14. assert_array_equal(inp, strings)
  15. expected = strings.copy()
  16. expected[1, :] = 'AAA'
  17. assert_array_equal(out, expected)