public void NonAbbreviationLabel()
        {
            var tokens = new List <string>();

            Assert.IsFalse(AbbreviationLabel.Parse("A Random Label - Don't Reverse", tokens));
            Assert.AreEqual(1, tokens.Count);
        }
        public void Hydrate()
        {
            var tokens = new List <string>();

            AbbreviationLabel.Parse("•H2O", tokens);
            Assert.IsTrue(tokens.SequenceEqual(new string[] { "•", "H2", "O" }));
        }
        public void Triphenylmethyl()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("CPh3", tokens));
            Assert.AreEqual(2, tokens.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { "C", "Ph3" }, tokens));
        }
        public void ParseBrackets()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("N(CH2CH2O)CH2", tokens));
            Assert.AreEqual(10, tokens.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { "N", "(", "C", "H2", "C", "H2", "O", ")", "C", "H2" }, tokens));
        }
        public void ReversingBracketsWithNumbers()
        {
            List <string> tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("B(OH)2", tokens));
            AbbreviationLabel.Reverse(tokens);
            Assert.AreEqual("(HO)2B", string.Join("", tokens));
        }
        public void ReversingBrackets()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("N(CH2CH2O)CH2", tokens));
            AbbreviationLabel.Reverse(tokens);
            Assert.AreEqual("H2C(OH2CH2C)N", string.Join("", tokens));
        }
        public void CO2Et()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("CO2Et", tokens));
            Assert.AreEqual(3, tokens.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { "C", "O2", "Et" }, tokens));
        }
        public void Peglinker()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("CH2CH2OCH2CH2O", tokens));
            Assert.AreEqual(10, tokens.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { "C", "H2", "C", "H2", "O", "C", "H2", "C", "H2", "O" }, tokens));
        }
        public void Carboxylate()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("COO-", tokens));
            Assert.AreEqual(4, tokens.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { "C", "O", "O", "-" }, tokens));
        }
        public void ParseFeacac3()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("Fe(acac)3", tokens));
            Assert.AreEqual(5, tokens.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { "Fe", "(", "acac", ")", "3" }, tokens));
        }
        public void ReversingFormatPOOHOEt()
        {
            List <string> tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("PO(OH)OEt", tokens));
            AbbreviationLabel.Reverse(tokens);
            AbbreviationLabel.Format(tokens);
            Assert.AreEqual("EtO(HO)OP", string.Join("", tokens));
        }
        public void Tertbutyls()
        {
            var tokens = new List <string>(1);

            foreach (var str in new[] { "tBu", "tertBu", "t-Bu", "t-Butyl", "tertButyl" })
            {
                tokens.Clear();
                Assert.IsTrue(AbbreviationLabel.Parse(str, tokens), str);
                Assert.AreEqual(1, tokens.Count);
            }
        }
        public void FormatFeacac3()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("Fe(acac)3", tokens));
            List <AbbreviationLabel.FormattedText> formatted = AbbreviationLabel.Format(tokens);

            Assert.AreEqual("Fe(acac)", formatted[0].Text);
            Assert.AreEqual(0, formatted[0].Style);
            Assert.AreEqual("3", formatted[1].Text);
            Assert.AreEqual(-1, formatted[1].Style);
        }
Exemple #14
0
        public AtomSymbol GenerateAbbreviatedSymbol(string label, HydrogenPosition position)
        {
            var tokens = new List <string>();

            if (AbbreviationLabel.Parse(label, tokens))
            {
                return(GenerateAbbreviationSymbol(tokens, position));
            }
            else
            {
                return(new AtomSymbol(new TextOutline(label, font, emSize), Array.Empty <TextOutline>()));
            }
        }
        public void FormatRubpy3Cl2()
        {
            var tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("Ru(bpy)3Cl2", tokens));
            var formatted = AbbreviationLabel.Format(tokens);

            AbbreviationLabel.Reduce(formatted, 0, formatted.Count);
            Assert.AreEqual("Ru(bpy)", formatted[0].Text);
            Assert.AreEqual(0, formatted[0].Style);
            Assert.AreEqual("3", formatted[1].Text);
            Assert.AreEqual(-1, formatted[1].Style);
            Assert.AreEqual("Cl", formatted[2].Text);
            Assert.AreEqual(0, formatted[2].Style);
            Assert.AreEqual("2", formatted[3].Text);
            Assert.AreEqual(-1, formatted[3].Style);
        }
        public void NEt3DotHCl()
        {
            List <string> tokens = new List <string>();

            Assert.IsTrue(AbbreviationLabel.Parse("NEt3·HCl", tokens));
            Assert.AreEqual(5, tokens.Count);
            Assert.AreEqual("N", tokens[0]);
            Assert.AreEqual("Et3", tokens[1]);
            Assert.AreEqual("·", tokens[2]);
            Assert.AreEqual("H", tokens[3]);
            Assert.AreEqual("Cl", tokens[4]);
            List <AbbreviationLabel.FormattedText> formatted = AbbreviationLabel.Format(tokens);

            AbbreviationLabel.Reduce(formatted, 0, formatted.Count);
            Assert.AreEqual(3, formatted.Count);
            Assert.AreEqual("NEt", formatted[0].Text);
            Assert.AreEqual(AbbreviationLabel.STYLE_NORMAL, formatted[0].Style);
            Assert.AreEqual("3", formatted[1].Text);
            Assert.AreEqual(AbbreviationLabel.STYLE_SUBSCRIPT, formatted[1].Style);
            Assert.AreEqual("·HCl", formatted[2].Text);
            Assert.AreEqual(AbbreviationLabel.STYLE_NORMAL, formatted[2].Style);
        }
 public void Het()
 {
     // 'Het' not 'He'lium and 't'erts
     Assert.IsFalse(AbbreviationLabel.Parse("Het", new List <string>()));
 }
 public void ParseChargeOnly()
 {
     Assert.IsFalse(AbbreviationLabel.Parse("+", new List <string>()));
 }
 public void ParseNumberOnly()
 {
     Assert.IsFalse(AbbreviationLabel.Parse("1", new List <string>()));
 }
 public void NonAsciiLabel()
 {
     // phenyl
     Assert.IsFalse(AbbreviationLabel.Parse("苯基", new List <string>()));
 }