mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-10 04:35:03 -05:00
41 lines
1.2 KiB
Python
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
|