当前位置: 首页>>代码示例>>C#>>正文


C# Input.Advance方法代码示例

本文整理汇总了C#中Input.Advance方法的典型用法代码示例。如果您正苦于以下问题:C# Input.Advance方法的具体用法?C# Input.Advance怎么用?C# Input.Advance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Input的用法示例。


在下文中一共展示了Input.Advance方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AdvancingInputAtEOL_ResetsColumnNumber

 public void AdvancingInputAtEOL_ResetsColumnNumber()
 {
     var i = new Input("\nabc");
     var j = i.Advance();
     Assert.AreEqual(2, j.Line);
     Assert.AreEqual(1, j.Column);
 }
开发者ID:PeteShearer,项目名称:Sprache,代码行数:7,代码来源:InputTests.cs

示例2: TestInputHashCode

        public void TestInputHashCode()
        {
            var input0 = new Input(SampleInput);
            var input1 = new Input(SampleInput);

            Assert.True(input0.GetHashCode() == input1.GetHashCode(), "same GetHashCode");

            input0 = input0.Advance();

            Assert.False(input0.GetHashCode() == input1.GetHashCode(), "different GetHashCode if advanced");
        }
开发者ID:speps,项目名称:Parler,代码行数:11,代码来源:InputTests.cs

示例3: TestInputAdvance

 public void TestInputAdvance()
 {
     var inputStart = new Input(SampleInput);
     var input = inputStart.Advance();
     Assert.Equal('H', inputStart.Current);
     Assert.Equal('e', input.Current);
     input = input.Advance();
     Assert.Equal('l', input.Current);
     input = input.Advance();
     Assert.Equal('l', input.Current);
 }
开发者ID:speps,项目名称:Parler,代码行数:11,代码来源:InputTests.cs

示例4: TestInputDrop

        public void TestInputDrop()
        {
            var input = new Input(SampleInput);
            input = input.Advance();

            var dropped = input.Drop(5);

            Assert.Equal('W', dropped.Current);
            Assert.Equal(6, dropped.Position);

            dropped = input.Drop(input.Source.Length + 4);

            Assert.True(dropped.EOF, "dropping past end sets EOF");
        }
开发者ID:speps,项目名称:Parler,代码行数:14,代码来源:InputTests.cs

示例5: TestSuccessEqualityDifferentInputDifferentValue

        public void TestSuccessEqualityDifferentInputDifferentValue()
        {
            var input0 = new Input(SampleInput);
            var input1 = new Input(SampleInput);

            // explicit cast because == is compile time bound, ISuccess won't work
            var success0 = Result.Success(input0.Advance(), "Hell") as Success;
            var success1 = Result.Success(input1, "ell") as Success;

            Assert.False(success0.Equals(success1), "ISuccess.Equals");
            Assert.False(success0 == success1, "operator==");
            Assert.True(success0 != success1, "operator!=");
            Assert.False(success0.GetHashCode() == success1.GetHashCode(), "GetHashCode");
        }
开发者ID:speps,项目名称:Parler,代码行数:14,代码来源:ResultTests.cs

示例6: TestFailureEqualityDifferentInput

        public void TestFailureEqualityDifferentInput()
        {
            var input0 = new Input(SampleInput);
            var input1 = new Input(SampleInput);

            // explicit cast because == is compile time bound, IFailure won't work
            var failure0 = Result.Failure(input0.Advance(), FailureType.SyntaxError) as Failure;
            var failure1 = Result.Failure(input1, FailureType.ExpectedLiteral) as Failure;

            Assert.False(failure0.Equals(failure1), "IFailure.Equals");
            Assert.False(failure0 == failure1, "operator==");
            Assert.True(failure0 != failure1, "operator!=");
            Assert.False(failure0.GetHashCode() == failure1.GetHashCode(), "GetHashCode");
        }
开发者ID:speps,项目名称:Parler,代码行数:14,代码来源:ResultTests.cs

示例7: TestInputEquality

        public void TestInputEquality()
        {
            var input0 = new Input(SampleInput);
            var input1 = new Input(SampleInput);

            Assert.True(input0.Equals(input1), "object.Equals");
            Assert.True(input0 == input1, "operator==");
            Assert.False(input0 != input1, "operator!=");

            input0 = input0.Advance();

            Assert.False(input0.Equals(input1), "advanced so not object.Equals");
            Assert.False(input0 == input1, "advanced so not operator==");
            Assert.True(input0 != input1, "advanced so operator!=");

            Assert.False(input0 == null, "== null returns false");
            Assert.True(input0 != null, "!= null returns true");
            Assert.False(input0.Equals(null), "Equals(null) returns false");
            Assert.False(input0.Equals("42"), "Equals(string) returns false");

            input0 = null;
            Assert.True(input0 == null, "== null returns true if null");
            Assert.False(input0 != null, "!= null returns false if null");
        }
开发者ID:speps,项目名称:Parler,代码行数:24,代码来源:InputTests.cs

示例8: TestInputTake

        public void TestInputTake()
        {
            var input = new Input(SampleInput);
            input = input.Advance();

            int positionBeforeTake = input.Position;
            var take5 = input.Take(5);

            Assert.True(positionBeforeTake == input.Position, "Take doesn't change Position");
            Assert.Equal("ello ", take5);

            var takeMore = input.Take(input.Source.Length + 4);
            Assert.Equal("ello World!", takeMore);
        }
开发者ID:speps,项目名称:Parler,代码行数:14,代码来源:InputTests.cs

示例9: InputsAtEnd_CannotAdvance

 public void InputsAtEnd_CannotAdvance()
 {
     var i = new Input("", 0);
     Assert.IsTrue(i.AtEnd);
     Assert.Throws<InvalidOperationException>(() => i.Advance());
 }
开发者ID:PeteShearer,项目名称:Sprache,代码行数:6,代码来源:InputTests.cs

示例10: AdvancingInput_MovesForwardOneCharacter

 public void AdvancingInput_MovesForwardOneCharacter()
 {
     var i = new Input("abc", 1);
     var j = i.Advance();
     Assert.AreEqual(2, j.Position);
 }
开发者ID:PeteShearer,项目名称:Sprache,代码行数:6,代码来源:InputTests.cs

示例11: AdvancingInput_IncreasesColumnNumber

 public void AdvancingInput_IncreasesColumnNumber()
 {
     var i = new Input("abc", 1);
     var j = i.Advance();
     Assert.AreEqual(2, j.Column);
 }
开发者ID:PeteShearer,项目名称:Sprache,代码行数:6,代码来源:InputTests.cs

示例12: AdvancingInputAtEOL_IncreasesLineNumber

 public void AdvancingInputAtEOL_IncreasesLineNumber()
 {
     var i = new Input("\nabc");
     var j = i.Advance();
     Assert.AreEqual(2, j.Line);
 }
开发者ID:PeteShearer,项目名称:Sprache,代码行数:6,代码来源:InputTests.cs


注:本文中的Input.Advance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。