Exemplo n.º 1
0
        [TestMethod] public void Flipping_Tuple_Ser()
        {
            var greedy = new BigIntFormatter();

            Assert.IsTrue(greedy.isGreedyDeserialize);
            var nonGreedy = new TerminateIntegerFormatter(true);

            Assert.IsFalse(nonGreedy.isGreedyDeserialize);

            var lim = (BigInteger)30_000;

            void TestTupleForm(IFormatter <BigInteger> f, IFormatter <BigInteger> s)
            {
                var form = new TupleFormatter <BigInteger, BigInteger>(f, s);

                foreach (var b in range.Range(-lim, lim))
                {
                    var bytes = form.serialize((b + 1, b - 1));
                    var(o, u) = form.deserialize(bytes);
                    Assert.AreEqual(o, b + 1);
                    Assert.AreEqual(u, b - 1);
                }
            }

            TestTupleForm(greedy, nonGreedy);
            TestTupleForm(nonGreedy, greedy);
            TestTupleForm(nonGreedy, nonGreedy);
            TestTupleForm(greedy, greedy);
        }
Exemplo n.º 2
0
 public MoneyFormatter()
 {
     _innerFormatter = new TupleFormatter <byte[], int>();
 }