"""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"), pytest.param(ir.ConstantInput(42), None, 42, id="ConstantInput"), pytest.param(ir.ConstantInput(-42), None, -42, id="ConstantInput"), ], ) def test_evaluate( node: ir.IntermediateNode, input_data, expected_result: int, ): """Test evaluate methods on IntermediateNodes""" assert node.evaluate(input_data) == expected_result