Example #1
0
        public void PseudoBigInt_InvalidFormat()
        {
            var badStrings = new[]
            {
                // 0    Zero-length input
                "",
                // 1    Leading zeroes on number
                "01",
                // 2    Leading zeroes on number
                "001",
                // 3    Leading zero on zero
                "00",
                // 4    Invalid character, negative sign
                "-1",
                // 5    Invalid character, close bottom of to numeric range
                "(1",
                // 6    Invalid character, close to top of numeric range
                "@1",
                // 7    Invalid character
                "f1",
                // 8    Invalid character, no numbers
                "uw",
                // 9    Invalid character, decimal point
                "10.2",
                // 10   Invalid character, decimal comma
                "10,2",
                // 11   Invalid character, E notation
                "1e3",
            };

            for (int i = 0; i < badStrings.Length; i++)
            {
                new Action(() => PseudoBigInt.Compare(badStrings[i], "555"))
                .AssertThrows <FormatException>(
                    $"Did not throw on invalid subject (input #{i})."
                    );

                new Action(() => PseudoBigInt.Compare("555", badStrings[i]))
                .AssertThrows <FormatException>(
                    $"Did not throw on invalid against (input #{i})."
                    );

                new Action(() => PseudoBigInt.Compare(badStrings[i], badStrings[i]))
                .AssertThrows <FormatException>(
                    $"Did not throw on both invalid (input #{i})."
                    );
            }
        }
Example #2
0
        public void PseudoBigInt_NullArguments()
        {
            new Action(() => PseudoBigInt.Compare(null, "555"))
            .AssertThrows <ArgumentNullException>(
                "Did not throw on null subject."
                );

            new Action(() => PseudoBigInt.Compare("555", null))
            .AssertThrows <ArgumentNullException>(
                "Did not throw on null against."
                );

            new Action(() => PseudoBigInt.Compare(null, null))
            .AssertThrows <ArgumentNullException>(
                "Did not throw on both null."
                );
        }