public void Should_partition_string()
 {
     var p = new StringPartition("left=right", "=");
     Assert.AreEqual("left", p.LeftString);
     Assert.AreEqual("=", p.Separator);
     Assert.AreEqual("right", p.RightString);
 }
 public void Should_partition_string_no_sep_match()
 {
     var p = new StringPartition("left", "=");
     Assert.AreEqual("left", p.LeftString);
     Assert.AreEqual("", p.Separator);
     Assert.AreEqual("", p.RightString);
 }
Example #3
0
        public void Should_partition_string()
        {
            var p = new StringPartition("left=right", "=");

            Assert.AreEqual("left", p.LeftString);
            Assert.AreEqual("=", p.Separator);
            Assert.AreEqual("right", p.RightString);
        }
Example #4
0
 private static IEnumerable <string> GetAllSuffixes(int minSuffixLength, string word)
 {
     for (var i = word.Length - minSuffixLength; i >= 0; i--)
     {
         var partition = new StringPartition(word, i);
         yield return(partition.ToString());
     }
 }
Example #5
0
        public void Should_partition_string_no_sep_match()
        {
            var p = new StringPartition("left", "=");

            Assert.AreEqual("left", p.LeftString);
            Assert.AreEqual("", p.Separator);
            Assert.AreEqual("", p.RightString);
        }
Example #6
0
        public void SplitTest(string origin, int start, int length, int splitAt, string expectedHead,
                              string expectedRest)
        {
            var target = new StringPartition(origin, start, length);
            var actual = target.Split(splitAt);

            Assert.AreEqual(expectedHead, actual.Head);
            Assert.AreEqual(expectedRest, actual.Rest);
        }
Example #7
0
        public void StartsWithTest(string inputThis, string inputOther, bool expectedResult)
        {
            var target = new StringPartition(inputThis);
            var other  = new StringPartition(inputOther);

            var actual = target.StartsWith(other);

            Assert.AreEqual(expectedResult, actual);
        }
Example #8
0
        public void ZipTest(string inputThis, string inputOther, string expectedCommonHead, string expectedThisRest,
                            string expectedOtherRest)
        {
            var target = new StringPartition(inputThis);
            var other  = new StringPartition(inputOther);
            var actual = target.ZipWith(other);

            Assert.AreEqual(expectedCommonHead, actual.CommonHead.ToString());
            Assert.AreEqual(expectedThisRest, actual.ThisRest.ToString());
            Assert.AreEqual(expectedOtherRest, actual.OtherRest.ToString());
        }
Example #9
0
 public SplitResult(StringPartition head, StringPartition rest)
 {
     m_Head = head;
     m_Rest = rest;
 }
Example #10
0
 public ZipResult(StringPartition commonHead, StringPartition thisRest, StringPartition otherRest)
 {
     m_CommonHead = commonHead;
     m_ThisRest = thisRest;
     m_OtherRest = otherRest;
 }
 public SplitResult(StringPartition head, StringPartition rest)
 {
     this.m_Head = head;
     this.m_Rest = rest;
 }
Example #12
0
 public SplitResult(StringPartition head, StringPartition rest)
 {
     this.head = head;
     this.rest = rest;
 }