示例#1
0
 public void FromDelta_InvalidInput_Throws()
 {
     var delta = "=x";
     Assert.Throws<ArgumentException>(() => 
         DiffList.FromDelta("", delta).ToList()
     );
 }
示例#2
0
 public void FromDelta_GeneratesExpectedDiffs()
 {
     var delta = diffs.ToDelta();
     var result  = DiffList.FromDelta(diffs.Text1(), delta);
     Assert.Equal(diffs, result.ToList());
     
 }
示例#3
0
        public void ToDelta_InputTooShort_Throws()
        {
            var delta = diffs.ToDelta();
            var text1 = diffs.Text1().Substring(1);

            DiffList.FromDelta(text1, delta).ToList();
        }
示例#4
0
        public void ToDelta_InputTooLong_Throws()
        {
            var delta = diffs.ToDelta();
            var text1 = diffs.Text1() + "x";

            DiffList.FromDelta(text1, delta).ToList();
        }
示例#5
0
 public void FromDelta_InputTooLong_Throws()
 {
     var delta = diffs.ToDelta();
     var text1 = diffs.Text1() + "x";
     Assert.Throws<ArgumentException>(() =>
         DiffList.FromDelta(text1, delta).ToList()
     );
 }
        public void ToDelta_InputTooShort_Throws()
        {
            var diffs = new List <Diff>
            {
                Diff.Equal("jump"),
                Diff.Delete("s"),
                Diff.Insert("ed"),
                Diff.Equal(" over "),
                Diff.Delete("the"),
                Diff.Insert("a"),
                Diff.Equal(" lazy"),
                Diff.Insert("old dog")
            };
            var delta = diffs.ToDelta();
            var text1 = diffs.Text1().Substring(1);

            Assert.Throws <ArgumentException>(() => DiffList.FromDelta(text1, delta).ToList());
        }
        public void FromDelta_GeneratesExpectedDiffs()
        {
            var diffs = new List <Diff>
            {
                Diff.Equal("jump"),
                Diff.Delete("s"),
                Diff.Insert("ed"),
                Diff.Equal(" over "),
                Diff.Delete("the"),
                Diff.Insert("a"),
                Diff.Equal(" lazy"),
                Diff.Insert("old dog")
            };
            var delta  = diffs.ToDelta();
            var result = DiffList.FromDelta(diffs.Text1(), delta);

            CollectionAssert.AreEqual(diffs, result.ToList());
        }
        public void Delta_LargeString()
        {
            // 160 kb string.
            var a = "abcdefghij";

            for (var i = 0; i < 14; i++)
            {
                a += a;
            }
            var diffs2 = new List <Diff> {
                Diff.Insert(a)
            };
            var delta = diffs2.ToDelta();

            Assert.AreEqual("+" + a, delta);

            // Convert delta string into a diff.
            CollectionAssert.AreEqual(diffs2, DiffList.FromDelta("", delta).ToList(), "diff_fromDelta: 160kb string.");
        }
        public void Delta_FromUnchangedCharacters_Succeeds()
        {
            // Verify pool of unchanged characters.
            var expected = new List <Diff>
            {
                Diff.Insert("A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; / ? : @ & = + $ , # ")
            };
            var text2 = expected.Text2();

            Assert.AreEqual("A-Z a-z 0-9 - _ . ! ~ * \' ( ) ; / ? : @ & = + $ , # ", text2);

            var delta = expected.ToDelta();

            Assert.AreEqual("+A-Z a-z 0-9 - _ . ! ~ * \' ( ) ; / ? : @ & = + $ , # ", delta);

            // Convert delta string into a diff.
            var actual = DiffList.FromDelta("", delta);

            CollectionAssert.AreEqual(expected, actual.ToList(), "diff_fromDelta: Unchanged characters.");
        }
        public void Delta_SpecialCharacters_Works()
        {
            var zero   = (char)0;
            var one    = (char)1;
            var two    = (char)2;
            var diffs2 = new List <Diff>
            {
                Diff.Equal("\u0680 " + zero + " \t %"),
                Diff.Delete("\u0681 " + one + " \n ^"),
                Diff.Insert("\u0682 " + two + " \\ |")
            };
            var text1 = diffs2.Text1();

            Assert.AreEqual("\u0680 " + zero + " \t %\u0681 " + one + " \n ^", text1);

            var delta = diffs2.ToDelta();

            // Lowercase, due to UrlEncode uses lower.
            Assert.AreEqual("=7\t-7\t+%da%82 %02 %5c %7c", delta, "diff_toDelta: Unicode.");

            CollectionAssert.AreEqual(diffs2, DiffList.FromDelta(text1, delta).ToList(), "diff_fromDelta: Unicode.");
        }
示例#11
0
 public void FromDelta_EmptyTokensAreOk()
 {
     var delta = "\t\t";
     var diffs = DiffList.FromDelta("", delta);
     Assert.Empty(diffs);
 }
 public void FromDelta_InvalidUnicodeInput_Throws()
 {
     DiffList.FromDelta("", "+%c3%xy").ToList();
 }