コード例 #1
0
        private void AssertConversion(string projectText, string initialCircuit)
        {
            TestSocket test = new TestSocket(new ProjectTester(this.TestContext, projectText, initialCircuit));

            test.Tester.CircuitProject.InTransaction(() => {
                for (int i = 0; i < test.Tester.Input.Length; i++)
                {
                    int bitWidth = test.Tester.Input[i].BitWidth;
                    for (int value = 0; value < (1 << bitWidth); value++)
                    {
                        test.Tester.Input[i].Value = value;
                        Assert.AreEqual(value, test.Tester.Input[i].Value, "Value set incorrectly");
                        Assert.IsTrue(test.Tester.CircuitState.Evaluate(true), "Evaluation should be successful");
                        Assert.AreEqual(value, test.Value(i, bitWidth), "Incorrect result");
                    }
                    test.Tester.Input[i].Value = 1 << bitWidth;
                    Assert.AreEqual(0, test.Tester.Input[i].Value, "Input should accept values < 1 << bitWidth");
                }
            });
        }