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


C# Token.CompareTo方法代码示例

本文整理汇总了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);
        }
开发者ID:rwindegger,项目名称:TextAnalysisPlayground,代码行数:17,代码来源:TokenTests.cs

示例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);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:10,代码来源:Token.Facts.cs

示例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);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:9,代码来源:Token.Facts.cs

示例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);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:10,代码来源:Token.Facts.cs

示例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);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:10,代码来源:Token.Facts.cs

示例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);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:10,代码来源:Token.Facts.cs

示例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);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:10,代码来源:Token.Facts.cs


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