本文整理汇总了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);
}
示例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");
}
示例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);
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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);
}
示例9: InputsAtEnd_CannotAdvance
public void InputsAtEnd_CannotAdvance()
{
var i = new Input("", 0);
Assert.IsTrue(i.AtEnd);
Assert.Throws<InvalidOperationException>(() => i.Advance());
}
示例10: AdvancingInput_MovesForwardOneCharacter
public void AdvancingInput_MovesForwardOneCharacter()
{
var i = new Input("abc", 1);
var j = i.Advance();
Assert.AreEqual(2, j.Position);
}
示例11: AdvancingInput_IncreasesColumnNumber
public void AdvancingInput_IncreasesColumnNumber()
{
var i = new Input("abc", 1);
var j = i.Advance();
Assert.AreEqual(2, j.Column);
}
示例12: AdvancingInputAtEOL_IncreasesLineNumber
public void AdvancingInputAtEOL_IncreasesLineNumber()
{
var i = new Input("\nabc");
var j = i.Advance();
Assert.AreEqual(2, j.Line);
}