コード例 #1
0
        public void NonVote_5()
        {
            string   line     = "[] Forgot to x the vote";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #2
0
        public void NonVote_4()
        {
            string   line     = "--- Waaaait a minute...";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #3
0
        public void NonVote_6()
        {
            string   line     = "{x] Wrong brackets";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #4
0
        public void NonVote_7()
        {
            string   line     = "[[x] More wrong brackets";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #5
0
        public void NonVote_9()
        {
            string   line     = "~~[x] Invalid prefix";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #6
0
        public void NonVote_8()
        {
            string   line     = "[-x] Improperly placed prefix";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #7
0
        public void NonVote_3()
        {
            string   line     = "[JK] A joke vote";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #8
0
        public void NonVote_2()
        {
            string   line     = "A discussion.  Make sure to [X] your vote.";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #9
0
        public void NonVote_1()
        {
            string   line     = "A basic vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #10
0
        public void NonVote_10()
        {
            string   line     = "[-2] Invalid rank";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            Assert.AreEqual(null, voteLine);
        }
コード例 #11
0
        public void Strip_BBCode_None()
        {
            string cleanExample = @"Text Nagisa's uncle about her visiting today. Establish a specific time. (Keep in mind Sayaka's hospital visit.)";

            string result = VoteLineParser.StripBBCode(cleanExample);

            Assert.AreEqual(cleanExample, result);
        }
コード例 #12
0
        public void Strip_BBCode_Image_Url()
        {
            string clean        = "Fancy <Image>";
            string imageExample = @"Fancy 『url='http://google.com/image/1.jpg'』<Image>『/url』";

            string result = VoteLineParser.StripBBCode(imageExample);

            Assert.AreEqual(clean, result);
        }
コード例 #13
0
        public void Strip_BBCode_More()
        {
            string cleanExample = @"Text Nagisa's uncle about her visiting today. Establish a specific time. (Keep in mind Sayaka's hospital visit.)";
            string largeExample = @"Text Nagisa's uncle about her 『i』visiting『/i』 today. Establish a 『b』specific time『/b』. 『color=orange』(Keep in mind Sayaka's hospital visit.)『/color』";

            string result = VoteLineParser.StripBBCode(largeExample);

            Assert.AreEqual(cleanExample, result);
        }
コード例 #14
0
        public void Strip_BBCode_Url()
        {
            string clean      = "Vote for me!";
            string urlExample = @"Vote for 『url=""http://google.com/myhome.html""』me『/url』!";

            string result = VoteLineParser.StripBBCode(urlExample);

            Assert.AreEqual(clean, result);
        }
コード例 #15
0
        public void Strip_BBCode_UserRef_Url()
        {
            string clean      = "@Xryuran";
            string urlExample = @"『url=""https://forum.questionablequesting.com/members/2392/""』@Xryuran『/url』";

            string result = VoteLineParser.StripBBCode(urlExample);

            Assert.AreEqual(clean, result);
        }
コード例 #16
0
        public void Task_Complex_Spacing()
        {
            string   line     = "[X]  [Do you~~Go!] A normal vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("X", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("Do you~~Go!", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #17
0
        public void Prefix_DashEmDash()
        {
            string   line     = "-—[x] A normal vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("-—", voteLine.Prefix);
                Assert.AreEqual(2, voteLine.Depth);
                Assert.AreEqual("x", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #18
0
        public void Marker_HighRank()
        {
            string   line     = "[#10] A normal vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("#10", voteLine.Marker);
                Assert.AreEqual(MarkerType.Rank, voteLine.MarkerType);
                Assert.AreEqual(9, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #19
0
        public void Marker_BracketedCheckbox()
        {
            string   line     = "[☑] A normal vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("☑", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #20
0
        public void Marker_Score_Overflow()
        {
            string   line     = "[200%] A normal vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("200%", voteLine.Marker);
                Assert.AreEqual(MarkerType.Score, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #21
0
        public void Marker_Disapproval()
        {
            string   line     = "[-] A normal vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("-", voteLine.Marker);
                Assert.AreEqual(MarkerType.Approval, voteLine.MarkerType);
                Assert.AreEqual(20, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #22
0
        public void Task_Bold()
        {
            string   line     = "[X][『b』Tasky『/b』] A normal vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("X", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("Tasky", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #23
0
        public void Unbalanced_Multiple_Missing_Middle()
        {
            string   line     = "[X][Tasky] 『b』『i』Vote for stuff『/b』";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("X", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("『b』Vote for stuff『/b』", voteLine.Content);
                Assert.AreEqual("Vote for stuff", voteLine.CleanContent);
                Assert.AreEqual("Tasky", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #24
0
        public void Unbalanced_Early_Content()
        {
            string   line     = "[X][Tasky] A normal 『b』vote line";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("X", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("A normal vote line", voteLine.CleanContent);
                Assert.AreEqual("Tasky", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #25
0
        public void General_Bold_Full()
        {
            string   line     = "『b』[X][Tasky] A normal vote line『/b』";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("X", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("A normal vote line", voteLine.Content);
                Assert.AreEqual("A normal vote line", voteLine.CleanContent);
                Assert.AreEqual("Tasky", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #26
0
        public void General_Bold_Task()
        {
            string line = @"[X]『i』『b』[Shopping]『/b』『/i』 Shopping 1";
            // Poor matching may result in the Content ==> 『i』『b』『/b』『/i』 Shopping 1
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("X", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                Assert.AreEqual("Shopping 1", voteLine.Content);
                Assert.AreEqual("Shopping 1", voteLine.CleanContent);
                Assert.AreEqual("Shopping", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #27
0
        public void Unbalanced_Multiple_Long_Colors()
        {
            string   line     = "[X][Tasky] Brutalize them. You haven’t had a chance to properly fight in 『/color』『i』『color=#ebebeb』years『/color』『/i』『color=#ebebeb』, and spars can only do so much. How thoughtful of the Herans to volunteer!";
            VoteLine?voteLine = VoteLineParser.ParseLine(line);

            if (voteLine != null)
            {
                Assert.AreEqual("", voteLine.Prefix);
                Assert.AreEqual(0, voteLine.Depth);
                Assert.AreEqual("X", voteLine.Marker);
                Assert.AreEqual(MarkerType.Vote, voteLine.MarkerType);
                Assert.AreEqual(100, voteLine.MarkerValue);
                // Convert ’ to '
                Assert.AreEqual("Brutalize them. You haven't had a chance to properly fight in 『i』『color=#ebebeb』years『/color』『/i』, and spars can only do so much. How thoughtful of the Herans to volunteer!", voteLine.Content);
                Assert.AreEqual("Brutalize them. You haven't had a chance to properly fight in years, and spars can only do so much. How thoughtful of the Herans to volunteer!", voteLine.CleanContent);
                Assert.AreEqual("Tasky", voteLine.Task);
            }

            Assert.AreNotEqual(null, voteLine);
        }
コード例 #28
0
ファイル: Benchmarks.cs プロジェクト: MizMahem/NetTally
        public void Time_VoteLine_Parsing_and_Construction()
        {
            using (var rp = new RegionProfiler("Warm up"))
            {
            }

            string   input1, input2, input3, input4;
            string?  line1, line2, line3, line4;
            string?  prefix, marker, task, content;
            VoteLine?vote1, vote2, vote3, vote4;
            object   o1, o2, o3, o4;

            input1 = "It depends, but the general trend is that it's easier once you've done it once. So, one day you're at 5 San and you killed a Witch by binding it's existence to a giant, abstract clock made of your own crystallized blood, dooming it to die when it strikes twelve.";
            input2 = "[X][Other] Ask about the time you \"met\" before. Make sure she remembers it.";
            input3 = "[X] Ask about the time you \"met\" before. Make sure she remembers it.";
            input4 = "[x][To Do?] 『b』A 『url='http://example.com/image.jpg'』normal『/url』 day at the beach.『/b』";

            using (var rp = new RegionProfiler("Baseline with empty vote lines"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    o1 = VoteLine.Empty;
                    o2 = VoteLine.Empty;
                    o3 = VoteLine.Empty;
                    o4 = VoteLine.Empty;
                }
            }

            using (var rp = new RegionProfiler("Time constructing vote lines"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    vote1 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                    vote2 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                    vote3 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                    vote4 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                }
            }

            using (var rp = new RegionProfiler("Time parsing lines"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    vote1 = VoteLineParser.ParseLine(input1);
                    vote2 = VoteLineParser.ParseLine(input2);
                    vote3 = VoteLineParser.ParseLine(input3);
                    vote4 = VoteLineParser.ParseLine(input4);
                }
            }

            using (var rp = new RegionProfiler("Time parsing strings"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input1)).Success)
                    {
                        line1 = VoteString.CleanVoteLineBBCode(input1);
                        VoteString.GetVoteComponents(line1, out prefix, out marker, out task, out content);
                    }
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input2)).Success)
                    {
                        line2 = VoteString.CleanVoteLineBBCode(input2);
                        VoteString.GetVoteComponents(line2, out prefix, out marker, out task, out content);
                    }
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input3)).Success)
                    {
                        line3 = VoteString.CleanVoteLineBBCode(input3);
                        VoteString.GetVoteComponents(line3, out prefix, out marker, out task, out content);
                    }
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input4)).Success)
                    {
                        line4 = VoteString.CleanVoteLineBBCode(input4);
                        VoteString.GetVoteComponents(line4, out prefix, out marker, out task, out content);
                    }
                }
            }

            using (var rp = new RegionProfiler("Comparing parsed lines"))
            {
                vote1 = VoteLineParser.ParseLine(input1);
                vote2 = VoteLineParser.ParseLine(input2);
                vote3 = VoteLineParser.ParseLine(input3);
                vote4 = VoteLineParser.ParseLine(input4);

                for (int i = 0; i < 2500; i++)
                {
                    if (vote1 == vote4 || vote2 == vote3)
                    {
                        o1 = new object();
                    }
                }
            }

            using (var rp = new RegionProfiler("Comparing parsed lines"))
            {
                if (voteLineRegex.Match(VoteString.RemoveBBCode(input1)).Success)
                {
                    line1 = VoteString.CleanVoteLineBBCode(input1);
                }
                else
                {
                    line1 = null;
                }

                if (voteLineRegex.Match(VoteString.RemoveBBCode(input2)).Success)
                {
                    line2 = VoteString.CleanVoteLineBBCode(input2);
                }
                else
                {
                    line2 = null;
                }

                if (voteLineRegex.Match(VoteString.RemoveBBCode(input3)).Success)
                {
                    line3 = VoteString.CleanVoteLineBBCode(input3);
                }
                else
                {
                    line3 = null;
                }

                if (voteLineRegex.Match(VoteString.RemoveBBCode(input4)).Success)
                {
                    line4 = VoteString.CleanVoteLineBBCode(input4);
                }
                else
                {
                    line4 = null;
                }

                for (int i = 0; i < 2500; i++)
                {
                    if (
                        //Agnostic.StringComparer.Equals(VoteString.GetVoteContent(line1), VoteString.GetVoteContent(line2)) ||
                        Agnostic.StringComparer.Equals(VoteString.GetVoteContent(line3 !), VoteString.GetVoteContent(line4 !))
                        )
                    {
                        o1 = new object();
                    }
                }
            }


            VoteLine vote = new VoteLine("", "", "", "", MarkerType.None, 0);

            Assert.AreEqual(VoteLine.Empty, vote);
        }