本文整理汇总了C#中Parser.CallReset方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.CallReset方法的具体用法?C# Parser.CallReset怎么用?C# Parser.CallReset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.CallReset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_ReadValidCSharpName_Fails
public void Test_ReadValidCSharpName_Fails()
{
var names = new[]
{
"$Foo",
"+foo",
"-A",
"\"A\"",
};
foreach (var name in names)
{
var parser = new Parser();
parser.CallReset(name);
var exceptionThrown = false;
try
{
var result = parser.CallReadValidCSharpName();
}
catch (MvxException)
{
exceptionThrown = true;
}
Assert.IsTrue(exceptionThrown);
}
}
示例2: DoReadEnumerationTest
private void DoReadEnumerationTest(Type enumerationType, string input, object expectedOutput)
{
var parser = new Parser();
parser.CallReset(input);
var output = parser.CallReadEnumerationValue(enumerationType, true /* ignoreCase */);
Assert.AreEqual(expectedOutput, output);
Assert.IsTrue(parser.GetIsComplete());
}
示例3: Test_ReadValidCSharpName_Succeeds
public void Test_ReadValidCSharpName_Succeeds()
{
var names = new[]
{
@"Foo",
@"foo",
@"A",
@"a",
@"_x",
@"x_x",
@"_2",
@"A5",
@"B_5_d",
@"B5_d_s_",
};
foreach (var name in names)
{
var parser = new Parser();
parser.CallReset(name);
var result = parser.CallReadValidCSharpName();
Assert.AreEqual(name, result);
Assert.IsTrue(parser.GetIsComplete());
var parser2 = new Parser();
parser2.CallReset("\t " + name + " \r \t");
var result2 = parser2.CallReadValidCSharpName();
Assert.AreEqual(name, result2);
Assert.IsFalse(parser2.GetIsComplete());
}
}
示例4: DoReadValueTest
private void DoReadValueTest(string input, object expectedOutput)
{
var parser = new Parser();
parser.CallReset(input);
var output = parser.CallReadValue();
Assert.AreEqual(expectedOutput, output);
Assert.IsTrue(parser.GetIsComplete());
}
示例5: Test_CallReadUnsignedInteger_Reads_Numbers
public void Test_CallReadUnsignedInteger_Reads_Numbers()
{
var testStrings = new Dictionary<string, uint>
{
{"2", 2},
{"1234", 1234},
{UInt32.MaxValue.ToString(), UInt32.MaxValue},
{UInt32.MinValue.ToString(), UInt32.MinValue},
};
foreach (var testString in testStrings)
{
var tokeniser = new Parser();
tokeniser.CallReset(testString.Key);
var result = tokeniser.CallReadUnsignedInteger();
Assert.AreEqual(testString.Value, result);
Assert.IsTrue(tokeniser.GetIsComplete());
}
}
示例6: Test_CallReadQuotedString_Reads_Strings
public void Test_CallReadQuotedString_Reads_Strings()
{
var testStrings = new Dictionary<string, string>
{
{"''", ""},
{"\"Hello \\\"\\\'\"", "Hello \"\'"},
{"\"Hello\"", "Hello"},
{"'Hello'", "Hello"},
{"'Hello World'", "Hello World"},
{"'Hello \\r'", "Hello \r"},
{"'Hello \\u1234'", "Hello \u1234"},
{"'Hello \\U00001234'", "Hello \U00001234"},
};
foreach (var testString in testStrings)
{
var tokeniser = new Parser();
tokeniser.CallReset(testString.Key);
var result = tokeniser.CallReadQuotedString();
Assert.AreEqual(testString.Value, result);
Assert.IsTrue(tokeniser.GetIsComplete());
}
}
示例7: Test_Reset_Clears_And_Sets_All_Properties
public void Test_Reset_Clears_And_Sets_All_Properties()
{
var tokeniser = new Parser();
Assert.IsNull(tokeniser.GetFullText());
Assert.AreEqual(0, tokeniser.GetCurrentIndex());
var testString1 = @"1 test";
tokeniser.CallReset(testString1);
Assert.AreEqual(testString1, tokeniser.GetFullText());
Assert.AreEqual(0, tokeniser.GetCurrentIndex());
Assert.AreEqual(testString1[0], tokeniser.GetCurrentChar());
var testString2 = @"2 test";
tokeniser.CallReset(testString2);
Assert.AreEqual(testString2, tokeniser.GetFullText());
Assert.AreEqual(0, tokeniser.GetCurrentIndex());
Assert.AreEqual(testString2[0], tokeniser.GetCurrentChar());
}
示例8: Test_ReadTextUntilWhitespaceOr_ReadsText
public void Test_ReadTextUntilWhitespaceOr_ReadsText()
{
var tests = new string[] { "fred;", "fred life;", "[email protected];", "fred", "fred\tlife;", "fred\n" };
foreach (var test in tests)
{
var parser = new Parser();
parser.CallReset(test);
var output = parser.CallReadTextUntilWhitespaceOr('@', ';', ')');
Assert.AreEqual("fred", output);
}
}