test_string.py 676 B

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