Skip to content

Commit

Permalink
add unit test of initialization without error
Browse files Browse the repository at this point in the history
  • Loading branch information
ShisatoYano committed Sep 5, 2024
1 parent 1f72537 commit 57c4287
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/test_cubic_spline_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@
sys.path.append(str(Path(__file__).absolute().parent) + "/../src/components/course/cubic_spline_course")
from cubic_spline import CubicSpline

X_DATA_VALID = [0, 1, 2, 3, 4]
X_DATA_INVALID = [0, -1, -2, 3, 5]
Y_DATA = [1.7, -6, 5, 6.5, 0.0]

def test_init_value_error():
x_points = [0, -1, -2, 3, 5]
y_points = [1.7, -6, 5, 6.5, 0.0]

def test_init_value_error():
with pytest.raises(ValueError) as e:
CubicSpline(x_points, y_points)
CubicSpline(X_DATA_INVALID, Y_DATA)

assert str(e.value) == "X coordinate points must be stored in ascending order"


def test_init_no_error():
cs = CubicSpline(X_DATA_VALID, Y_DATA)

assert cs.x_points == X_DATA_VALID
assert cs.y_points == Y_DATA

0 comments on commit 57c4287

Please sign in to comment.