本文整理汇总了C#中Lexer.Lexer.ParseFieldOptions方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.ParseFieldOptions方法的具体用法?C# Lexer.ParseFieldOptions怎么用?C# Lexer.ParseFieldOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer.Lexer
的用法示例。
在下文中一共展示了Lexer.ParseFieldOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseFieldOptions_NOK04
public void ParseFieldOptions_NOK04()
{
const string text = " [default = 123";
var field = new Field { FieldType = FieldType.TypeInt32, HasOption = false };
var lex = new Lexer(text) { Matches = Helper.SplitText(text) };
Assert.IsFalse(lex.ParseFieldOptions(field));
Assert.AreEqual(2, lex.Tokens.Count);
Assert.AreEqual(1, lex.Errors.Count);
Assert.AreEqual(4, lex.Index);
}
示例2: ParseFieldOptions_OK01
public void ParseFieldOptions_OK01()
{
const string text = " [default=123, packed=true];";
var field = new Field { FieldType = FieldType.TypeInt32, HasOption = false };
var lex = new Lexer(text) { Matches = Helper.SplitText(text) };
Assert.IsTrue(lex.ParseFieldOptions(field));
Assert.AreEqual(4, lex.Tokens.Count);
Assert.AreEqual(0, lex.Errors.Count);
Assert.AreEqual(9, lex.Index);
Assert.AreEqual(3, lex.Tokens[0].Position);
Assert.AreEqual(11, lex.Tokens[1].Position);
Assert.AreEqual(16, lex.Tokens[2].Position);
Assert.AreEqual(23, lex.Tokens[3].Position);
Assert.AreEqual(7, lex.Tokens[0].Length);
Assert.AreEqual(3, lex.Tokens[1].Length);
Assert.AreEqual(6, lex.Tokens[2].Length);
Assert.AreEqual(4, lex.Tokens[3].Length);
Assert.AreEqual(CodeType.Keyword, lex.Tokens[0].CodeType);
Assert.AreEqual(CodeType.Number, lex.Tokens[1].CodeType);
Assert.AreEqual(CodeType.Keyword, lex.Tokens[2].CodeType);
Assert.AreEqual(CodeType.Keyword, lex.Tokens[3].CodeType);
}