Bump version to 0.3.0 due to breaking changes in this PR
Update tests
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import math
|
||||
import pytest
|
||||
from src.basic_data_handling.float_nodes import (
|
||||
FloatCreate,
|
||||
FloatAdd,
|
||||
FloatSubtract,
|
||||
FloatMultiply,
|
||||
FloatDivide,
|
||||
FloatDivideSafe,
|
||||
FloatPower,
|
||||
FloatRound,
|
||||
FloatIsInteger,
|
||||
@@ -12,6 +15,15 @@ from src.basic_data_handling.float_nodes import (
|
||||
FloatFromHex,
|
||||
)
|
||||
|
||||
def test_float_create():
|
||||
node = FloatCreate()
|
||||
assert node.create("3.14") == (3.14,)
|
||||
assert node.create("-2.5") == (-2.5,)
|
||||
assert node.create("0.0") == (0.0,)
|
||||
with pytest.raises(ValueError):
|
||||
node.create("not a number")
|
||||
|
||||
|
||||
def test_float_add():
|
||||
node = FloatAdd()
|
||||
assert node.add(2.2, 2.2) == (4.4,)
|
||||
@@ -41,6 +53,20 @@ def test_float_divide():
|
||||
node.divide(5.0, 0.0)
|
||||
|
||||
|
||||
def test_float_divide_safe():
|
||||
node = FloatDivideSafe()
|
||||
|
||||
assert node.divide(7.0, 2.0) == (3.5,)
|
||||
assert node.divide(-6.0, 3.0) == (-2.0,)
|
||||
assert node.divide(5.0, 0.0) == (float('inf'),)
|
||||
assert node.divide(-5.0, 0.0) == (float('-inf'),)
|
||||
|
||||
# Special handling for NaN because NaN != NaN
|
||||
result = node.divide(0.0, 0.0)
|
||||
assert len(result) == 1
|
||||
assert math.isnan(result[0])
|
||||
|
||||
|
||||
def test_float_power():
|
||||
node = FloatPower()
|
||||
assert node.power(2.0, 3.0) == (8.0,)
|
||||
|
||||
Reference in New Issue
Block a user