summaryrefslogtreecommitdiff
path: root/numpy/f2py/tests/test_string.py
blob: 065861c0bd83485ed4c9dbae79330fe2eca876fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from __future__ import division, absolute_import, print_function

import os

from numpy.testing import run_module_suite, assert_array_equal, dec
import numpy as np
from . import util


def _path(*a):
    return os.path.join(*((os.path.dirname(__file__),) + a))

class TestString(util.F2PyTest):
    sources = [_path('src', 'string', 'char.f90')]

    @dec.slow
    def test_char(self):
        strings = np.array(['ab', 'cd', 'ef'], dtype='c').T
        inp, out = self.module.char_test.change_strings(strings, strings.shape[1])
        assert_array_equal(inp, strings)
        expected = strings.copy()
        expected[1, :] = 'AAA'
        assert_array_equal(out, expected)

if __name__ == "__main__":
    run_module_suite()