예제 #1
0
        public void _46a_AjouterPlusieurs()
        {
            ArbreBin <int> ab = null;

            AreEqual(5, Ajouter(ref ab, new [] { 5, 5, 2, 2, 9, 9, 7, 7, 4, 4, 5 }));
            AreEqual("n 4 2 | 7 n 9 | 5 |", ab.EnTexte());

            ab = null;
            AreEqual(5, Ajouter(ref ab, new[] { 1, 2, 3, 4, 5 }));
            AreEqual("n n n n 5 4 | 3 | 2 | 1 |", ab.EnTexte());

            ab = null;
            AreEqual(5, Ajouter(ref ab, new[] { 5, 4, 3, 2, 1 }));
            AreEqual("1 n 2 | n 3 | n 4 | n 5 |", ab.EnTexte());
        }
예제 #2
0
        public void _46b_AjouterPlusieursRandom()
        {
            ArbreBin <int> ab = null;

            AreEqual(10, Ajouter(ref ab, Enumerable.Range(1, 10), new Random(1)));
            AreEqual("1 3 n 4 | 2 | 6 5 | 8 10 9 | 7 |", ab.EnTexte());
        }
예제 #3
0
        public void _45a_AjouterUn()
        {
            ArbreBin <int> ab = null;

            AreEqual(true, Ajouter(ref ab, 5));
            AreEqual("5", ab.EnTexte());

            AreEqual(false, Ajouter(ref ab, 5));
            AreEqual("5", ab.EnTexte());

            Ajouter(ref ab, 2);
            AreEqual("2 n 5 |", ab.EnTexte());

            Ajouter(ref ab, 9);
            AreEqual("2 9 5 |", ab.EnTexte());

            Ajouter(ref ab, 7);
            AreEqual("2 7 n 9 | 5 |", ab.EnTexte());

            AreEqual(true, Ajouter(ref ab, 4));
            AreEqual(false, Ajouter(ref ab, 4));
            AreEqual(false, Ajouter(ref ab, 5));
            AreEqual(false, Ajouter(ref ab, 9));
            AreEqual("n 4 2 | 7 n 9 | 5 |", ab.EnTexte());
        }
예제 #4
0
        public void _61x_NouvelArbreBalancé()
        {
            ArbreBin <int> ab = NouvelArbreBalancé(new int[0]);

            AreEqual("n", ab.EnTexte());

            ab = NouvelArbreBalancé(Enumerable.Range(1, 15).ToArray());
            AreEqual("8f + 0t + 7e = 15n", ÉquationFTEN(ab));

            ab = NouvelArbreBalancé(Enumerable.Range(1, 16).ToArray());
            AreEqual("8f + 1t + 7e = 16n", ÉquationFTEN(ab));

            ThrowsException <ArgumentException>(() => NouvelArbreBalancé(new[] { 2, 2 }));
            ThrowsException <ArgumentException>(() => NouvelArbreBalancé(new[] { 2, 1 }));
        }