コード例 #1
0
        public void UpdateArrayTest()
        {
            BinaryArrayInLong target = new BinaryArrayInLong();

            target.UpdateArray(new bool[] { false, false, false, false, false, false, false, false });
            long received = target.GetValue();

            Assert.IsTrue(received == 0, "Expected 0 but received " + received);

            target.UpdateArray(new bool[] { true, false, true, false, true, false, true, false, true, false, true, false });
            received = target.GetValue();
            Assert.IsTrue(received == 1365, "Expected 1365 but received " + received);

            target.UpdateArray(new bool[] { false, true, false, true, false, true, false, true, false, true, false, true });
            received = target.GetValue();
            Assert.IsTrue(received == 2730, "Expected 2730 but received " + received);

            bool[] allTrue = new bool[64];
            for (int i = 0; i < 64; i++)
            {
                allTrue[i] = true;
            }
            target.UpdateArray(allTrue);
            received = target.GetValue();
            Assert.IsTrue(received == -1, "Expected -1 but received " + received);
        }
コード例 #2
0
        public void ItemTest()
        {
            BinaryArrayInLong target = new BinaryArrayInLong();
            Random            r      = new Random();

            for (int pass = 1; pass < 4; pass++)
            {
                bool[] expected = new bool[64];

                for (int i = 0; i < 64; i++)
                {
                    expected[i] = (r.Next(2) == 1);
                    target[i]   = expected[i];
                }

                // read the values and compare with the expected
                for (int i = 0; i < 64; i++)
                {
                    bool received = target[i];
                    Assert.IsTrue(received == expected[i], "Stored data do not match at index " + i + "; pass: "******"; received: " + received.ToString() + "; expected: " + expected[i]);
                }
            }
        }