import controlboros
import numpy as np


def test_dynamics_single_input():
    """Test dynamics equation with single input."""

    a = np.array([[1.0, 2.0], [0.0, 1.0]])
    b = np.array([[1.0], [3.0]])
    c = np.zeros((1, 2))

    s = controlboros.StateSpace(a, b, c)

    assert np.all(s.dynamics([1.0, 1.0], [1.0]) == np.array([4.0, 4.0]))


def test_dynamics_multiple_inputs():
    """Test dynamics equation with multiple inputs."""

    a = np.array([[1.0, 2.0], [0.0, 1.0]])
    b = np.array([[1.0, 2.0], [3.0, 2.0]])
    c = np.zeros((1, 2))

    s = controlboros.StateSpace(a, b, c)

    assert np.all(s.dynamics([1.0, 1.0], [1.0, 0.0]) == np.array([4.0, 4.0]))


def test_output_siso():
    """Test output equation with single input, single output."""

    a = np.zeros((2, 2))
    b = np.zeros((2, 1))
    c = np.array([[1.0, 1.0]])
    d = np.array([[2.0]])

    s = controlboros.StateSpace(a, b, c, d)

    assert s.output([1.0, 1.0], [1.0]) == np.array([4.0])


def test_output_simo():
    """Test output equation with single input, multiple outputs."""

    a = np.zeros((2, 2))
    b = np.zeros((2, 1))
    c = np.eye(2)
    d = np.array([[2.0], [3.0]])

    s = controlboros.StateSpace(a, b, c, d)

    assert np.all(s.output([1.0, 1.0], [1.0]) == np.array([3.0, 4.0]))


def test_output_miso():
    """Test output equation with multiple inputs, single output."""

    a = np.zeros((2, 2))
    b = np.zeros((2, 2))
    c = np.array([[1.0, 1.0]])
    d = np.array([[2.0, 3.0]])

    s = controlboros.StateSpace(a, b, c, d)

    assert np.all(s.output([1.0, 1.0], [1.0, 1.0]) == np.array([7.0]))


def test_output_mimo():
    """Test output equation with multiple inputs, multiple outputs."""

    a = np.zeros((2, 2))
    b = np.zeros((2, 2))
    c = np.eye(2)
    d = np.eye(2)

    s = controlboros.StateSpace(a, b, c, d)

    assert np.all(s.output([1.0, 1.0], [2.0, 3.0]) == np.array([3.0, 4.0]))

@@ -32,16 +32,30 @@
 y as np%0A
+import pytest%0A
 %0A%0Adef te
@@ -1905,28 +1905,1405 @@
 %5D) == np.array(%5B3.0, 4.0%5D))%0A
+%0A%0Adef test_invalid_dynamics_matrix_dimensions():%0A    %22%22%22Test exception if A is not square.%22%22%22%0A    a = np.zeros((2, 1))%0A    b = np.zeros((2, 1))%0A    c = np.zeros((1, 2))%0A%0A    with pytest.raises(ValueError) as excinfo:%0A        s = controlboros.StateSpace(a, b, c)%0A    assert %22Invalid matrix dimensions%22 in str(excinfo.value)%0A%0A%0Adef test_invalid_input_matrix_dimensions():%0A    %22%22%22Test exception if B and A have different number of rows.%22%22%22%0A    a = np.zeros((2, 2))%0A    b = np.zeros((1, 1))%0A    c = np.zeros((1, 2))%0A%0A    with pytest.raises(ValueError) as excinfo:%0A        s = controlboros.StateSpace(a, b, c)%0A    assert %22Invalid matrix dimensions%22 in str(excinfo.value)%0A%0A%0Adef test_invalid_output_matrix_dimensions():%0A    %22%22%22Test exception if C and A have different number of columns.%22%22%22%0A    a = np.zeros((2, 2))%0A    b = np.zeros((2, 1))%0A    c = np.zeros((1, 3))%0A%0A    with pytest.raises(ValueError) as excinfo:%0A        s = controlboros.StateSpace(a, b, c)%0A    assert %22Invalid matrix dimensions%22 in str(excinfo.value)%0A%0A%0Adef test_invalid_feedthrough_matrix_dimensions():%0A    %22%22%22Test exception if D does not match to B and C.%22%22%22%0A    a = np.zeros((2, 2))%0A    b = np.zeros((2, 3))%0A    c = np.zeros((4, 2))%0A    d = np.zeros((4, 2))%0A%0A    with pytest.raises(ValueError) as excinfo:%0A        s = controlboros.StateSpace(a, b, c, d)%0A    assert %22Invalid matrix dimensions%22 in str(excinfo.value)%0A

Add unit test for validation of A, B, C, D dimensions