Example #1
0
        static void TestFr()
        {
            Console.WriteLine("TestFr");
            Fr x = new Fr();

            x.Clear();
            assert("0", x.ToString() == "0");
            assert("0.IzZero", x.IsZero());
            assert("!0.IzOne", !x.IsOne());
            x.SetInt(1);
            assert("1", x.ToString() == "1");
            assert("!1.IzZero", !x.IsZero());
            assert("1.IzOne", x.IsOne());
            x.SetInt(3);
            assert("3", x.ToString() == "3");
            assert("!3.IzZero", !x.IsZero());
            assert("!3.IzOne", !x.IsOne());
            x.SetInt(-5);
            x = -x;
            assert("5", x.ToString() == "5");
            x.SetInt(4);
            x = x * x;
            assert("16", x.ToString() == "16");
            Fr y;

            y = x.Clone();
            assert("x == y", x.Equals(y));
            x.SetInt(123);
            assert("123", x.ToString() == "123");
            assert("y != x", !x.Equals(y));
            try {
                x.SetStr("1234567891234x");
                Console.WriteLine("x = {0}", x);
            } catch (Exception e) {
                Console.WriteLine("exception test OK\n'{0}'", e);
            }
            x.SetStr("1234567891234");
            assert("1234567891234", x.ToString() == "1234567891234");
        }