Пример #1
0
        public void TestChercheDierese()
        {
            List <ZonePoeme> zpL = AnalyseDierese.ChercheDierese(ttt, pws, 0);
            StringBuilder    sb  = new StringBuilder();

            //foreach (ZonePoeme zp in zpL)
            //{
            //    foreach (Vers v in zp.vList)
            //    {
            //        sb.AppendLine(v.Syllabes());
            //    }
            //}
            //Assert.AreEqual(expiationSyls, sb.ToString());

            TestTheText.CompareWordByWord(expiationSyls, TestTheText.ToSyllabes(pws));

            foreach (ZonePoeme zp in zpL)
            {
                foreach (Vers v in zp.vList)
                {
                    if (v.nrPieds > 4)
                    {
                        Assert.AreEqual(zp.nrPiedsVoulu, v.nrPieds);
                    }
                }
            }
        }
Пример #2
0
        public void TestDierese()
        {
            TestTheText ttt  = new TestTheText(expiation27);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            List <PhonWord> pws = ttt.GetPhonWordList(conf);

            foreach (PhonWord pw in pws)
            {
                pw.ComputeSyls();
            }
            Vers v = new Vers(ttt, 0, pws);

            Assert.AreEqual("Puis, à pas lents, musique en tête, sans fureur,", v.ToString());
            Assert.AreEqual("Puis à pas lents mu-sique en tê-te sans fu-reur", v.Syllabes());
            v.ChercheDierese(12);
            Assert.AreEqual("Puis à pas lents mu-sique en tê-te sans fu-reur", v.Syllabes());

            Vers v2 = new Vers(ttt, 50, pws);

            Assert.AreEqual("            Tranquille, souriant à la mitraille anglaise,", v2.ToString());
            Assert.AreEqual("Tran-quil-le sou-riant à la mi-traille an-glaise", v2.Syllabes());
            v2.ChercheDierese(12);
            Assert.AreEqual("Tran-quil-le sou-ri-ant à la mi-traille an-glaise", v2.Syllabes());

            Vers v3 = new Vers(ttt, 121, pws);

            Assert.AreEqual("La garde impériale entra dans la fournaise.", v3.ToString());
            Assert.AreEqual("La garde im-pé-riale en-tra dans la four-naise", v3.Syllabes());
            v3.ChercheDierese(12);
            Assert.AreEqual("La garde im-pé-ri-ale en-tra dans la four-naise", v3.Syllabes());
        }
Пример #3
0
        public void TestChiffres()
        {
            TestTheText ttt = new TestTheText(txt47);
            ColConfWin  ccw = conf.colors[PhonConfType.phonemes];
            Dictionary <string, CharFormatting> son2CF = SetTestConfig(ccw);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            int index = ttt.S.IndexOf("1867");

            ttt.AssertCF(index, son2CF["mil"]);
            ttt.AssertCF(index + 1, son2CF["cen"]);
            ttt.AssertCF(index + 2, son2CF["diz"]);
            ttt.AssertCF(index + 3, son2CF["uni"]);

            index = ttt.S.IndexOf("Rênal");
            ttt.AssertCF(index + 5, son2CF["uni"]);

            index = ttt.S.IndexOf("reme35rciant");
            ttt.AssertCF(index + 4, son2CF["diz"]);
            ttt.AssertCF(index + 5, son2CF["uni"]);

            index = ttt.S.IndexOf("23femme");
            ttt.AssertCF(index, son2CF["diz"]);
            ttt.AssertCF(index + 1, son2CF["uni"]);

            index = ttt.S.IndexOf("p45ar");
            ttt.AssertCF(index + 1, son2CF["diz"]);

            index = ttt.S.IndexOf("déc0123456789idé");
            ttt.AssertCF(index + 3, 6, son2CF["47"]);
            ttt.AssertCF(index + 9, son2CF["mil"]);
            ttt.AssertCF(index + 10, son2CF["cen"]);
            ttt.AssertCF(index + 11, son2CF["diz"]);
            ttt.AssertCF(index + 12, son2CF["uni"]);
        }
Пример #4
0
        private void CheckAlernateCF(CharFormatting cf1, CharFormatting cf2, CharFormatting cf3,
                                     Config c)
        {
            SylConfig syc = c.sylConf;

            syc.ResetCounter();
            for (int i = 0; i < 10; i++)
            {
                CharFormatting cfFirst = syc.NextCF();
                Assert.AreEqual(cf1, cfFirst);
                CharFormatting cfSecond = syc.NextCF();
                Assert.AreEqual(cf2, cfSecond);
                CharFormatting cfThird = syc.NextCF();
                Assert.AreEqual(cf3, cfThird);
            }

            syc.ResetCounter();
            TestTheText ttt = new TestTheText(text1);

            ttt.MarkWords(c);
            int index = ttt.S.IndexOf("Monsieur");

            ttt.AssertCF(index, 8, cf1);
            index = ttt.S.IndexOf("Poiret");
            ttt.AssertCF(index, 6, cf2);
            index = ttt.S.IndexOf("était");
            ttt.AssertCF(index, 5, cf3);
            index = ttt.S.IndexOf("une");
            ttt.AssertCF(index, 3, cf1);
            index = ttt.S.IndexOf("espèce");
            ttt.AssertCF(index, 6, cf2);
            index = ttt.S.IndexOf("couverte"); // pos 28
            ttt.AssertCF(index, 8, cf1);
        }
Пример #5
0
        public void Test8()
        {
            ZonePoeme zp         = new ZonePoeme(ttt);
            int       startLigne = 720;
            Vers      v;

            for (int i = 0; i < 48; i++)
            {
                v = new Vers(ttt, startLigne, pws);
                Assert.IsTrue(zp.AddVers(v));
                startLigne = v.Last + 2;
            }

            Assert.AreEqual(v8, zp.ToString());

            startLigne = zp.Last + 2;
            v          = new Vers(ttt, startLigne, pws);
            Assert.IsFalse(zp.AddVers(v));

            TestTheText.CompareWordByWord(v8Syls, zp.Syllabes());
            zp.ChercheDierese(0);
            TestTheText.CompareWordByWord(v8SylsDierese, zp.Syllabes());

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => zp.ChercheDierese(-1));
        }
Пример #6
0
        public void WriteSyllabes()
        {
            TheText.Init();

            TestTheText ttt  = new TestTheText(Texte);
            Config      conf = new Config();

            // ----------- c'est ici qu'on configure ce qu'on veut ------------------------
            conf.sylConf.mode = SylConfig.Mode.poesie;

            List <PhonWord> pws = ttt.GetPhonWordList(conf, true);

            foreach (PhonWord pw in pws)
            {
                pw.ComputeSyls();
            }

            List <ZonePoeme> zpL = AnalyseDierese.ChercheDierese(ttt, pws, 0);
            StringBuilder    sb  = new StringBuilder();

            foreach (ZonePoeme zp in zpL)
            {
                foreach (Vers v in zp.vList)
                {
                    sb.AppendLine(v.Syllabes());
                }
            }

            Console.Write(sb.ToString());
        }
Пример #7
0
        public void TestHarle()
        {
            TestTheText ttt  = new TestTheText(HarlesEtHiboux);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            ttt.AssertSyls(conf, HarlesEtHibouxPoesie);
        }
Пример #8
0
        public void TestCigogne()
        {
            TestTheText ttt  = new TestTheText(LeRenardEtLaCigogne);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            ttt.AssertSyls(conf, LeRenardEtLaCigognePoesie);
        }
Пример #9
0
        public void TestHymne()
        {
            TestTheText ttt  = new TestTheText(HymneALaBeaute);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            ttt.AssertSyls(conf, HymneALaBeautePoesie);
        }
Пример #10
0
        public void TestMethod3()
        {
            PBDQConfig pC = conf.pBDQ;

            CheckConsistency(pC);
            Assert.IsTrue(pC.UpdateLetter(0, 'M', TestTheText.fixCFs[0]));
            Assert.IsTrue(pC.UpdateLetter(1, 'P', TestTheText.fixCFs[1]));
            Assert.IsTrue(pC.UpdateLetter(2, 'e', TestTheText.fixCFs[2]));
            Assert.IsTrue(pC.UpdateLetter(3, 'h', TestTheText.fixCFs[3]));
            CheckConsistency(pC);

            TestTheText ttt = new TestTheText(text1);

            ttt.MarkLetters(conf);
            int index = ttt.S.IndexOf("Monsieur");

            ttt.AssertCF(index, TestTheText.fixCFs[0]);
            ttt.AssertCF(index + 5, TestTheText.fixCFs[2]);
            index = ttt.S.IndexOf("Poiret");
            ttt.AssertCF(index, TestTheText.fixCFs[1]);
            index = ttt.S.IndexOf("cachait");
            ttt.AssertCF(index + 3, TestTheText.fixCFs[3]);

            string Ms = ttt.GetCharsInCol(TestTheText.fixCols[0]);

            Assert.IsTrue(Ms.Length > 0);
            foreach (char c in Ms)
            {
                Assert.AreEqual('M', c);
            }

            string Ps = ttt.GetCharsInCol(TestTheText.fixCols[1]);

            Assert.IsTrue(Ps.Length > 0);
            foreach (char c in Ps)
            {
                Assert.AreEqual('P', c);
            }

            string es = ttt.GetCharsInCol(TestTheText.fixCols[2]);

            Assert.IsTrue(es.Length > 0);
            foreach (char c in es)
            {
                Assert.AreEqual('e', c);
            }

            string hs = ttt.GetCharsInCol(TestTheText.fixCols[3]);

            Assert.IsTrue(hs.Length > 0);
            foreach (char c in hs)
            {
                Assert.AreEqual('h', c);
            }
        }
Пример #11
0
        public void TestFormatage1()
        {
            UnsetBehConf uB  = conf.unsetBeh;
            ColConfWin   ccw = conf.colors[PhonConfType.phonemes];
            SylConfig    sC  = conf.sylConf;

            RGB            color   = new RGB(25, 100, 200);
            RGB            hiColor = new RGB(200, 100, 25);
            CharFormatting cfAll   = new CharFormatting(true, true, true, true, true, color, true, hiColor);

            ccw.SetCbxAndCF("m", cfAll);

            TestTheText ttt = new TestTheText(text1);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, true);
            ttt.AssertItalic(0, true);
            ttt.AssertUnderline(0, true);
            ttt.AssertColor(0, color);
            ttt.AssertChangeHilight(0, true);
            ttt.AssertHilightColor(0, hiColor);
            ttt.AssertBold(10, true); // La config par défaut fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ccw.SetCerasRose();
            uB.SetCbuFlag("Bold", true);
            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, true);
            ttt.AssertUnderline(0, true);
            ttt.AssertColor(0, color);
            ttt.AssertChangeHilight(0, true);
            ttt.AssertHilightColor(0, hiColor);
            ttt.AssertBold(10, true); // Ceras rosé fait ça.
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("All", true);
            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, false);
            ttt.AssertUnderline(0, false);
            ttt.AssertColor(0, TestTheText.black);
            ttt.AssertChangeHilight(0, false);
            ttt.AssertBold(10, true); // Ceras rosé fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ttt.ColorizePhons(conf, PhonConfType.muettes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, false);
            ttt.AssertUnderline(0, false);
            ttt.AssertColor(0, TestTheText.black);
            ttt.AssertChangeHilight(0, false);
            ttt.AssertBold(10, false);
            ttt.AssertColor(10, TestTheText.black);
        }
Пример #12
0
 public void MyTestInitialize()
 {
     ttt  = new TestTheText(expiation);
     conf = new Config();
     conf.sylConf.mode = SylConfig.Mode.poesie;
     pws = ttt.GetPhonWordList(conf, true);
     foreach (PhonWord pw in pws)
     {
         pw.ComputeSyls();
     }
 }
Пример #13
0
        public void TestTartuffe()
        {
            TestTheText ttt  = new TestTheText(Tartuffe);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            ttt.AssertSyls(conf, TartuffePoesie);

            conf.sylConf.chercherDierese = false;
            ttt.AssertSyls(conf, TartuffePoesieSansDierese);

            conf.sylConf.mode = SylConfig.Mode.ecrit;
            ttt.AssertSyls(conf, TartuffeEcrit);
        }
Пример #14
0
        public void TestExceptionsConstructeur()
        {
            TestTheText ttt  = new TestTheText(expiation27);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            List <PhonWord> pws = ttt.GetPhonWordList(conf);

            foreach (PhonWord pw in pws)
            {
                pw.ComputeSyls();
            }

            Vers            v;
            List <PhonWord> emptyPws = new List <PhonWord>();

            Assert.ThrowsException <ArgumentNullException>(() => { v = new Vers(null, 0, pws); });
            Assert.ThrowsException <ArgumentNullException>(() => { v = new Vers(ttt, 0, null); });
            Assert.ThrowsException <ArgumentException>(() => { v = new Vers(ttt, 1000, pws); });
        }
Пример #15
0
        public void TestMethod5()
        {
            // La détection de syllabes et ses trois modes est testée suffisament ailleurs.
            // Il manque la véréfication que le marquage des muettes fonctionne.
            TestTheText ttt = new TestTheText(text1);

            // hypothèse: la config par défaut contient des paramètres qui marquent les syllabes
            conf.sylConf.mode           = SylConfig.Mode.ecrit;
            conf.sylConf.marquerMuettes = true;
            conf.colors[PhonConfType.muettes].SetCFSon("_muet", TestTheText.fixCFs[0]);
            ttt.MarkSyls(conf);

            int index = ttt.S.IndexOf("Monsieur");

            ttt.AssertColor(index + 7, TestTheText.fixCols[0]);
            index = ttt.S.IndexOf("était");
            ttt.AssertColor(index + 4, TestTheText.fixCols[0]);
            index = ttt.S.IndexOf("long");
            ttt.AssertColor(index + 3, TestTheText.fixCols[0]);
        }
Пример #16
0
        public void TestPernelle()
        {
            TestTheText ttt  = new TestTheText(Pernelle);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            ttt.AssertSyls(conf, PernellePoesie);

            conf.sylConf.chercherDierese = false;
            ttt.AssertSyls(conf, PernellePoesieSansDierese);

            conf.sylConf.chercherDierese = true;
            conf.sylConf.nbrPieds        = 13;
            ttt.AssertSyls(conf, PernellePoesie13);

            conf.sylConf.nbrPieds = 10;
            ttt.AssertSyls(conf, PernellePoesieSansDierese);

            conf.sylConf.mode = SylConfig.Mode.oral;
            ttt.AssertSyls(conf, PernelleOral);
        }
Пример #17
0
        public void TestConstructeur()
        {
            TestTheText ttt  = new TestTheText(expiation27);
            Config      conf = new Config();

            conf.sylConf.mode = SylConfig.Mode.poesie;
            List <PhonWord> pws = ttt.GetPhonWordList(conf);

            foreach (PhonWord pw in pws)
            {
                pw.ComputeSyls();
            }
            Vers v = new Vers(ttt, 0, pws);

            Assert.AreEqual("Puis, à pas lents, musique en tête, sans fureur,", v.ToString());
            Assert.AreEqual("Puis à pas lents mu-sique en tê-te sans fu-reur", v.Syllabes());

            Vers v2 = new Vers(ttt, 50, pws);

            Assert.AreEqual("            Tranquille, souriant à la mitraille anglaise,", v2.ToString());
            Assert.AreEqual("Tran-quil-le sou-riant à la mi-traille an-glaise", v2.Syllabes());
        }
Пример #18
0
        private void CheckAlernateCF(CharFormatting cf1, Config c)
        {
            SylConfig syc = c.sylConf;

            syc.ResetCounter();
            for (int i = 0; i < 10; i++)
            {
                CharFormatting cf = syc.NextCF();
                Assert.AreEqual(cf1, cf);
            }

            TestTheText ttt = new TestTheText(text1);

            ttt.MarkWords(c);
            int index = ttt.S.IndexOf("Poiret");

            ttt.AssertCF(index, 6, cf1);
            index = ttt.S.IndexOf("était");
            ttt.AssertCF(index, 5, cf1);
            index = ttt.S.IndexOf("espèce");
            ttt.AssertCF(index, 6, cf1);
        }
Пример #19
0
        public void Test151()
        {
            ZonePoeme zp         = new ZonePoeme(ttt);
            int       startLigne = 0;
            Vers      v;

            for (int i = 0; i < 15; i++)
            {
                v = new Vers(ttt, startLigne, pws);
                Assert.IsTrue(zp.AddVers(v));
                startLigne = v.Last + 2;
            }

            Assert.AreEqual(exp31Premiers15, zp.ToString());

            startLigne = zp.Last + 2;
            v          = new Vers(ttt, startLigne, pws);
            Assert.IsFalse(zp.AddVers(v));
            TestTheText.CompareWordByWord(exp31Prem15Syls, zp.Syllabes());
            zp.ChercheDierese(0);
            TestTheText.CompareWordByWord(exp31Prem15SylsDierese, zp.Syllabes());
        }
Пример #20
0
        public void TestMethod4()
        {
            // Il faut vérifier que le flag markAsBlack a bien l'effet voulu.
            PBDQConfig  pC  = conf.pBDQ;
            TestTheText ttt = new TestTheText(text1);

            ttt.AssertColor(12, TestTheText.black);

            // Tout marquer avec un seul CF
            SylConfig sC = conf.sylConf;

            for (int i = SylConfig.NrButtons - 1; i >= 0; i--)
            {
                if (sC.ButtonIsLastActive(i))
                {
                    sC.ClearButton(i);
                }
            }
            conf.sylConf.SetSylButtonCF(0, TestTheText.fixCFs[7]);
            ttt.MarkWords(conf);

            ttt.AssertNotColor(12, TestTheText.black);
            ttt.AssertBold(12, true);
            CharFormatting cf12 = ttt.GetCF(12);

            pC.SetMarkAsBlackTo(false);

            Assert.IsTrue(pC.UpdateLetter(0, 'M', TestTheText.fixCFs[0]));
            Assert.IsTrue(pC.UpdateLetter(1, 'P', TestTheText.fixCFs[1]));
            Assert.IsTrue(pC.UpdateLetter(2, 'e', TestTheText.fixCFs[2]));
            Assert.IsTrue(pC.UpdateLetter(3, 'h', TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(4, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(5, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(6, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(7, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));

            Assert.IsFalse(pC.UpdateLetter(3, 'M', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(4, 'M', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(5, 'P', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(6, 'e', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(7, 'h', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(1, 'M', TestTheText.fixCFs[0]));
            Assert.AreEqual('M', pC.GetLetterForButtonNr(0));
            Assert.AreEqual('P', pC.GetLetterForButtonNr(1));
            Assert.AreEqual('e', pC.GetLetterForButtonNr(2));
            Assert.AreEqual('h', pC.GetLetterForButtonNr(3));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(4));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(5));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(6));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(7));

            pC.SetMarkAsBlackTo(false);
            Assert.AreEqual(pC.GetCfForPBDQLetter(
                                PBDQConfig.inactiveLetter), CharFormatting.NeutralCF);
            pC.SetMarkAsBlackTo(true);
            Assert.AreEqual(pC.GetCfForPBDQLetter(
                                PBDQConfig.inactiveLetter), TestTheText.blackCF);

            Assert.IsTrue(pC.UpdateLetter(4, 'x', TestTheText.fixCFs[4]));
            Assert.IsTrue(pC.UpdateLetter(5, 'y', TestTheText.fixCFs[5]));
            Assert.IsTrue(pC.UpdateLetter(6, 'z', TestTheText.fixCFs[6]));
            Assert.IsTrue(pC.UpdateLetter(7, '§', TestTheText.fixCFs[7]));
            CheckConsistency(pC);

            pC.SetMarkAsBlackTo(false);
            ttt.MarkLetters(conf);
            int index = ttt.S.IndexOf("Monsieur");

            ttt.AssertColor(index, TestTheText.fixCols[0]);
            ttt.AssertColor(index + 5, TestTheText.fixCols[2]);
            index = ttt.S.IndexOf("Poiret");
            ttt.AssertColor(index, TestTheText.fixCols[1]);
            index = ttt.S.IndexOf("cachait");
            ttt.AssertColor(index + 3, TestTheText.fixCols[3]);
            ttt.AssertNotColor(12, TestTheText.black);
            ttt.AssertCF(12, cf12);
            ttt.AssertBold(12, true);
            CheckConsistency(pC);

            pC.SetMarkAsBlackTo(true);
            ttt.MarkLetters(conf);
            index = ttt.S.IndexOf("Monsieur");
            ttt.AssertColor(index, TestTheText.fixCols[0]);
            ttt.AssertColor(index + 5, TestTheText.fixCols[2]);
            index = ttt.S.IndexOf("Poiret");
            ttt.AssertColor(index, TestTheText.fixCols[1]);
            index = ttt.S.IndexOf("cachait");
            ttt.AssertColor(index + 3, TestTheText.fixCols[3]);
            ttt.AssertColor(12, TestTheText.black);
            ttt.AssertBold(12, true);

            pC.Reset();
            Assert.IsFalse(pC.markAsBlack);
            Assert.AreEqual(ColConfWinTest.cf5, pC.GetCfForPBDQLetter('p'));
            Assert.AreEqual(ColConfWinTest.cfu, pC.GetCfForPBDQLetter('b'));
            Assert.AreEqual(ColConfWinTest.cfBLEU, pC.GetCfForPBDQLetter('d'));
            Assert.AreEqual(ColConfWinTest.cfON, pC.GetCfForPBDQLetter('q'));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(4));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(5));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(6));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(7));
        }
Пример #21
0
        public void TestFormatage2()
        {
            UnsetBehConf uB  = conf.unsetBeh;
            ColConfWin   ccw = conf.colors[PhonConfType.phonemes];
            SylConfig    sC  = conf.sylConf;

            RGB            color   = new RGB(25, 100, 200);
            RGB            hiColor = new RGB(200, 100, 25);
            CharFormatting cfAll   = new CharFormatting(true, true, true, true, true, color, true, hiColor);

            ccw.SetCbxAndCF("p", cfAll);
            TestTheText ttt = new TestTheText(text1);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, true);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true); // La config par défaut fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ttt.MarkLetters(conf); // ça ne devrait pas toucher au P majuscule...
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, true);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("Italic", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("Underline", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, false);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("All", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, false);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, false);
            ttt.AssertColor(9, TestTheText.black);
            ttt.AssertChangeHilight(9, false);
            ttt.AssertBold(10, false);
            ttt.AssertColor(10, TestTheText.black);
        }
Пример #22
0
        public void TestMiseEnCouleur()
        {
            ColConfWin ccw = conf.colors[PhonConfType.phonemes];
            Dictionary <string, CharFormatting> son2CF = SetTestConfig(ccw);
            TestTheText ttt = new TestTheText(text1);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            int index = ttt.S.IndexOf("Monsieur");

            ttt.AssertCF(index, 1, son2CF["m"]);
            ttt.AssertCF(index + 1, 2, son2CF["q"]);
            ttt.AssertCF(index + 3, 1, son2CF["s"]);
            ttt.AssertCF(index + 4, 1, son2CF["j"]);
            ttt.AssertCF(index + 5, 2, son2CF["2"]);
            ttt.AssertCF(index + 7, 1, son2CF["_muet"]);

            index = ttt.S.IndexOf("imparfaitement");
            ttt.AssertCF(index, 2, son2CF["5"]);
            ttt.AssertCF(index + 2, 1, son2CF["p"]);
            ttt.AssertCF(index + 3, 1, son2CF["a"]);
            ttt.AssertCF(index + 4, 1, son2CF["r"]);
            ttt.AssertCF(index + 5, 1, son2CF["f"]);
            ttt.AssertCF(index + 6, 2, son2CF["è"]);
            ttt.AssertCF(index + 8, 1, son2CF["t"]);
            ttt.AssertCF(index + 9, 1, son2CF["q"]);
            ttt.AssertCF(index + 10, 1, son2CF["m"]);
            ttt.AssertCF(index + 11, 2, son2CF["an"]);
            ttt.AssertCF(index + 13, 1, son2CF["_muet"]);

            Assert.AreEqual(ColConfWin.IllRule.ceras, ccw.IllRuleToUse);
            index = ttt.S.IndexOf("papillonnent");
            ttt.AssertCF(index, 1, son2CF["p"]);
            ttt.AssertCF(index + 1, 1, son2CF["a"]);
            ttt.AssertCF(index + 2, 1, son2CF["p"]);
            ttt.AssertCF(index + 3, 3, son2CF["ill"]);
            ttt.AssertCF(index + 6, 1, son2CF["o"]);
            ttt.AssertCF(index + 7, 2, son2CF["n"]);
            ttt.AssertCF(index + 9, 1, son2CF["q_caduc"]);
            ttt.AssertCF(index + 10, 2, son2CF["_muet"]);

            index = ttt.S.IndexOf("couverte");
            ttt.AssertCF(index, 1, son2CF["k"]);
            ttt.AssertCF(index + 1, 2, son2CF["u"]);
            ttt.AssertCF(index + 3, 1, son2CF["v"]);
            ttt.AssertCF(index + 4, 1, son2CF["è"]);
            ttt.AssertCF(index + 5, 1, son2CF["r"]);
            ttt.AssertCF(index + 6, 1, son2CF["t"]);
            ttt.AssertCF(index + 7, 1, son2CF["q_caduc"]);

            index = ttt.S.IndexOf("ombre");
            ttt.AssertCF(index, 2, son2CF["on"]);
            ttt.AssertCF(index + 2, 1, son2CF["b"]);
            ttt.AssertCF(index + 3, 1, son2CF["r"]);
            ttt.AssertCF(index + 4, 1, son2CF["q_caduc"]);

            index = ttt.S.IndexOf("mécanique");
            ttt.AssertCF(index, 1, son2CF["m"]);
            ttt.AssertCF(index + 1, 1, son2CF["é"]);
            ttt.AssertCF(index + 2, 1, son2CF["k"]);
            ttt.AssertCF(index + 3, 1, son2CF["a"]);
            ttt.AssertCF(index + 4, 1, son2CF["n"]);
            ttt.AssertCF(index + 5, 1, son2CF["i"]);
            ttt.AssertCF(index + 6, 2, son2CF["k"]);
            ttt.AssertCF(index + 8, 1, son2CF["q_caduc"]);

            index = ttt.S.IndexOf("culotte");
            ttt.AssertCF(index, 1, son2CF["k"]);
            ttt.AssertCF(index + 1, 1, son2CF["y"]);
            ttt.AssertCF(index + 2, 1, son2CF["l"]);
            ttt.AssertCF(index + 3, 1, son2CF["o"]);
            ttt.AssertCF(index + 4, 2, son2CF["t"]);
            ttt.AssertCF(index + 6, 1, son2CF["q_caduc"]);

            index = ttt.S.IndexOf("Poiret");
            ttt.AssertCF(index, 1, son2CF["p"]);
            ttt.AssertCF(index + 1, 2, son2CF["oi"]);
            ttt.AssertCF(index + 3, 1, son2CF["r"]);
            ttt.AssertCF(index + 4, 2, son2CF["è"]);

            TestTheText ttt2 = new TestTheText("pria");

            ttt2.ColorizePhons(conf, PhonConfType.phonemes);
            ttt2.AssertCF(0, 1, son2CF["p"]);
            ttt2.AssertCF(1, 1, son2CF["r"]);
            ttt2.AssertCF(2, 1, son2CF["ij"]);
            ttt2.AssertCF(3, 1, son2CF["a"]);

            index = ttt.S.IndexOf(@"celles d’un");
            ttt.AssertCF(index + 9, 2, son2CF["1"]);

            ttt2 = new TestTheText("soin");
            ttt2.ColorizePhons(conf, PhonConfType.phonemes);
            ttt2.AssertCF(0, 1, son2CF["s"]);
            ttt2.AssertCF(1, 3, son2CF["oin"]);

            ttt2 = new TestTheText("parking");
            ttt2.ColorizePhons(conf, PhonConfType.phonemes);
            ttt2.AssertCF(0, 1, son2CF["p"]);
            ttt2.AssertCF(1, 1, son2CF["a"]);
            ttt2.AssertCF(2, 1, son2CF["r"]);
            ttt2.AssertCF(3, 1, son2CF["k"]);
            ttt2.AssertCF(4, 1, son2CF["i"]);
            ttt2.AssertCF(5, 2, son2CF["ng"]);

            index = ttt.S.IndexOf("Jardin");
            ttt.AssertCF(index, 1, son2CF["ge"]);
            ttt.AssertCF(index + 1, 1, son2CF["a"]);
            ttt.AssertCF(index + 2, 1, son2CF["r"]);
            ttt.AssertCF(index + 3, 1, son2CF["d"]);
            ttt.AssertCF(index + 4, 2, son2CF["5"]);

            index = ttt.S.IndexOf("chinoise");
            ttt.AssertCF(index, 2, son2CF["ch"]);
            ttt.AssertCF(index + 2, 1, son2CF["i"]);
            ttt.AssertCF(index + 3, 1, son2CF["n"]);
            ttt.AssertCF(index + 4, 2, son2CF["oi"]);
            ttt.AssertCF(index + 6, 1, son2CF["z"]);
            ttt.AssertCF(index + 7, 1, son2CF["q_caduc"]);

            index = ttt.S.IndexOf("grise");
            ttt.AssertCF(index, 1, son2CF["g"]);
            ttt.AssertCF(index + 1, 1, son2CF["r"]);
            ttt.AssertCF(index + 2, 1, son2CF["i"]);
            ttt.AssertCF(index + 3, 1, son2CF["z"]);
            ttt.AssertCF(index + 4, 1, son2CF["q_caduc"]);

            ttt2 = new TestTheText("ligne");
            ttt2.ColorizePhons(conf, PhonConfType.phonemes);
            ttt2.AssertCF(0, 1, son2CF["l"]);
            ttt2.AssertCF(1, 1, son2CF["i"]);
            ttt2.AssertCF(2, 2, son2CF["gn"]);
            ttt2.AssertCF(4, 1, son2CF["q_caduc"]);

            ttt2 = new TestTheText("rixe");
            ttt2.ColorizePhons(conf, PhonConfType.phonemes);
            ttt2.AssertCF(0, 1, son2CF["r"]);
            ttt2.AssertCF(1, 1, son2CF["i"]);
            ttt2.AssertCF(2, 1, son2CF["ks"]);
            ttt2.AssertCF(3, 1, son2CF["q_caduc"]);

            ttt2 = new TestTheText("examen");
            ttt2.ColorizePhons(conf, PhonConfType.phonemes);
            ttt2.AssertCF(0, 1, son2CF["è"]);
            ttt2.AssertCF(1, 1, son2CF["gz"]);
            ttt2.AssertCF(2, 1, son2CF["a"]);
            ttt2.AssertCF(3, 1, son2CF["m"]);
            ttt2.AssertCF(4, 2, son2CF["5"]);

            ttt2 = new TestTheText("kiwi");
            ttt2.ColorizePhons(conf, PhonConfType.phonemes);
            ttt2.AssertCF(0, 1, son2CF["k"]);
            ttt2.AssertCF(1, 1, son2CF["i"]);
            ttt2.AssertCF(2, 1, son2CF["w"]);
            ttt2.AssertCF(3, 1, son2CF["i"]);

            ccw.IllRuleToUse = ColConfWin.IllRule.lirecouleur;
            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            Assert.AreEqual(ColConfWin.IllRule.lirecouleur, ccw.IllRuleToUse);
            index = ttt.S.IndexOf("papillonnent");
            ttt.AssertCF(index, 1, son2CF["p"]);
            ttt.AssertCF(index + 1, 1, son2CF["a"]);
            ttt.AssertCF(index + 2, 1, son2CF["p"]);
            ttt.AssertCF(index + 3, 1, son2CF["i"]);
            ttt.AssertCF(index + 4, 2, son2CF["j"]);
            ttt.AssertCF(index + 6, 1, son2CF["o"]);
            ttt.AssertCF(index + 7, 2, son2CF["n"]);
            ttt.AssertCF(index + 9, 1, son2CF["q_caduc"]);
            ttt.AssertCF(index + 10, 2, son2CF["_muet"]);
        }