Files
concrete/tests/common/representation/test_intermediate.py
Arthur Meyre be391ca388 chore: remove reference to package name and file paths
- avoids desync with the package name and file paths (which are unstable)
2021-08-02 13:01:52 +02:00

41 lines
1.2 KiB
Python

"""Test file for intermediate representation"""
import pytest
from hdk.common.data_types.integers import Integer
from hdk.common.data_types.values import ClearValue, EncryptedValue
from hdk.common.representation import intermediate as ir
@pytest.mark.parametrize(
"node,input_data,expected_result",
[
pytest.param(
ir.Add([EncryptedValue(Integer(64, False)), EncryptedValue(Integer(64, False))]),
[10, 4589],
4599,
id="Add",
),
pytest.param(
ir.Sub([EncryptedValue(Integer(64, False)), EncryptedValue(Integer(64, False))]),
[10, 4589],
-4579,
id="Sub",
),
pytest.param(
ir.Mul([EncryptedValue(Integer(64, False)), EncryptedValue(Integer(64, False))]),
[10, 4589],
45890,
id="Mul",
),
pytest.param(ir.Input(ClearValue(Integer(32, True)), "in", 0), [42], 42, id="Input"),
],
)
def test_evaluate(
node: ir.IntermediateNode,
input_data,
expected_result: int,
):
"""Test evaluate methods on IntermediateNodes"""
assert node.evaluate(input_data) == expected_result