本文整理汇总了C#中Token.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Token.CompareTo方法的具体用法?C# Token.CompareTo怎么用?C# Token.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.CompareTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TokenCompareToTest
public void TokenCompareToTest()
{
IComparable t1 = new Token { TokenStart = 10, TokenEnd = 20 };
IComparable t2 = new Token { TokenStart = 10, TokenEnd = 20 };
IComparable t3 = new Token { TokenStart = 5, TokenEnd = 20 };
IComparable t4 = new Token { TokenStart = 15, TokenEnd = 20 };
IComparable t5 = new Token { TokenStart = 10, TokenEnd = 15 };
IComparable t6 = new Token { TokenStart = 10, TokenEnd = 25 };
object t7 = new object();
Assert.AreEqual(0, t1.CompareTo(t2));
Assert.IsTrue(t1.CompareTo(t3) > 0);
Assert.IsTrue(t1.CompareTo(t4) < 0);
Assert.IsTrue(t1.CompareTo(t5) > 0);
Assert.IsTrue(t1.CompareTo(t6) < 0);
Assert.IsTrue(t1.CompareTo(t7) > 0);
}
示例2: op_CompareTo_objectUnequal_StringComparison
public void op_CompareTo_objectUnequal_StringComparison()
{
var obj = new Token("ABC");
var comparand = new Token("XYZ");
const int expected = -23;
var actual = obj.CompareTo(comparand, StringComparison.OrdinalIgnoreCase);
Assert.Equal(expected, actual);
}
示例3: op_CompareTo_objectSame
public void op_CompareTo_objectSame()
{
var obj = new Token("Example");
const int expected = 0;
var actual = obj.CompareTo(obj as object);
Assert.Equal(expected, actual);
}
示例4: op_CompareTo_objectLesser
public void op_CompareTo_objectLesser()
{
var obj = new Token("XYZ");
object comparand = new Token("ABC");
const int expected = 23;
var actual = obj.CompareTo(comparand);
Assert.Equal(expected, actual);
}
示例5: op_CompareTo_objectEqual_StringComparison
public void op_CompareTo_objectEqual_StringComparison()
{
var obj = new Token("EXAMPLE");
var comparand = new Token("example");
const int expected = 0;
var actual = obj.CompareTo(comparand, StringComparison.OrdinalIgnoreCase);
Assert.Equal(expected, actual);
}
示例6: op_CompareTo_objectEqual
public void op_CompareTo_objectEqual()
{
var obj = new Token("Example");
object comparand = new Token("Example");
const int expected = 0;
var actual = obj.CompareTo(comparand);
Assert.Equal(expected, actual);
}
示例7: op_CompareTo_TokenGreater
public void op_CompareTo_TokenGreater()
{
var obj = new Token("ABC");
var comparand = new Token("XYZ");
const int expected = -23;
var actual = obj.CompareTo(comparand);
Assert.Equal(expected, actual);
}