Exemple #1
0
 public int CompareTo(UInt128 other)
 {
     if (Hi != other.Hi)
     {
         return(Hi.CompareTo(other.Hi));
     }
     return(Lo.CompareTo(other.Lo));
 }
Exemple #2
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="ReservationId">An object to compare with.</param>
        public Int32 CompareTo(Reservation_Id ReservationId)
        {
            if ((Object)ReservationId == null)
            {
                throw new ArgumentNullException(nameof(ReservationId), "The given reservation identification must not be null!");
            }

            return(_Value.CompareTo(ReservationId._Value));
        }
Exemple #3
0
        public int CompareTo(TradeId other)
        {
            if (other == null)
            {
                return(1);
            }

            return(_id.CompareTo(other._id));
        }
Exemple #4
0
        /// <summary>
        /// Compares this instance to a specified <see cref="SecsUInt64"/> object and returns an integer that indicates their relationship to one another.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public int CompareTo(SecsUInt64 value)
        {
            if (value == null)
            {
                return(1);
            }

            return(_value.CompareTo(value._value));
        }
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="ChargingProfileId">An object to compare with.</param>
        public Int32 CompareTo(ChargingProfile_Id ChargingProfileId)
        {
            if ((Object)ChargingProfileId == null)
            {
                throw new ArgumentNullException(nameof(ChargingProfileId), "The given charging profile identification must not be null!");
            }

            return(_Value.CompareTo(ChargingProfileId._Value));
        }
Exemple #6
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="EVSEId">An object to compare with.</param>
        public Int32 CompareTo(EVSE_Id EVSEId)
        {
            if ((Object)EVSEId == null)
            {
                throw new ArgumentNullException(nameof(EVSEId), "The given EVSE identification must not be null!");
            }

            return(_Value.CompareTo(EVSEId._Value));
        }
Exemple #7
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="ConnectorId">An object to compare with.</param>
        public Int32 CompareTo(Connector_Id ConnectorId)
        {
            if ((Object)ConnectorId == null)
            {
                throw new ArgumentNullException(nameof(ConnectorId), "The given connector identification must not be null!");
            }

            return(_Value.CompareTo(ConnectorId._Value));
        }
Exemple #8
0
        public int CompareTo(IndexEntryV1 other)
        {
            var keyCmp = Key.CompareTo(other.Key);

            if (keyCmp != 0)
            {
                return(keyCmp);
            }
            return(Position.CompareTo(other.Position));
        }
Exemple #9
0
        public int CompareTo(BoolArray128 other)
        {
            int result = _data1.CompareTo(other._data1);

            if (result == 0)
            {
                result = _data0.CompareTo(other._data0);
            }

            return(result);
        }
 public static int CompareTo([JsFakeThis] UInt64 _this, object other)
 {
     if (other == null)
     {
         return(1);
     }
     if (!(other is UInt64))
     {
         throw new ArgumentException();
     }
     return(_this.CompareTo((UInt64)other));
 }
Exemple #11
0
        private void MethodTests()
        {
            featureTest.FailureMessage = "\tFailed UInt64 Method Test";
            featureTest.Send("UInt64 Method Test");
            UInt64 value1 = 1;
            UInt64 value2 = 2;
            UInt64 value3 = 3;
            Object obj1   = value1;
            Object obj2   = value2;
            Object obj3   = value3;

            featureTest.AssertTrue(value2.CompareTo(value1) > 0);
            featureTest.AssertTrue(value2.CompareTo(value3) < 0);
            featureTest.AssertTrue(value2.CompareTo(value2) == 0);

            featureTest.AssertTrue(value2.CompareTo(obj1) > 0);
            featureTest.AssertTrue(value2.CompareTo(obj3) < 0);
            featureTest.AssertTrue(value2.CompareTo(obj2) == 0);

            featureTest.AssertTrue(!value2.Equals(value1));
            featureTest.AssertTrue(!value2.Equals(value3));
            featureTest.AssertTrue(value2.Equals(value2));

            featureTest.AssertTrue(!value2.Equals(obj1));
            featureTest.AssertTrue(!value2.Equals(obj3));
            featureTest.AssertTrue(value2.Equals(obj2));
            featureTest.AssertTrue(UInt64.Parse("33") == 33);
            String str = 35.ToString();

            featureTest.AssertTrue(str == "35");
            UInt64 parsed;

            featureTest.AssertTrue(UInt64.TryParse(str, out parsed));
            featureTest.AssertTrue(parsed == 35);
        }
Exemple #12
0
 static void Test7()
 {
     Console.WriteLine("--- Test7");
     try
     {
         MyUInt64_2.CompareTo((object)(Int16)100);
         Console.WriteLine("Should raise a System.ArgumentException");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.GetType());
     }
 }
Exemple #13
0
        public int CompareTo(object obj)
        {
            int flag = 0;

            try {
                Student stu    = (Student)obj;
                UInt64  thisId = UInt64.Parse(this.id);
                UInt64  objId  = UInt64.Parse(stu.id);
                flag = thisId.CompareTo(objId);
            } catch (Exception ex) {
                throw new Exception("比较异常", ex.InnerException);
            }
            return(flag);
        }
Exemple #14
0
 public void TestCompareTo()
 {
     Assert.IsTrue(MyUInt64_3.CompareTo(MyUInt64_2) > 0);
     Assert.IsTrue(MyUInt64_2.CompareTo(MyUInt64_2) == 0);
     Assert.IsTrue(MyUInt64_1.CompareTo((UInt64)(42)) == 0);
     Assert.IsTrue(MyUInt64_2.CompareTo(MyUInt64_3) < 0);
     try {
         MyUInt64_2.CompareTo((object)(Int16)100);
         Assert.Fail("Should raise a System.ArgumentException");
     }
     catch (Exception e) {
         Assert.IsTrue(typeof(ArgumentException) == e.GetType());
     }
 }
Exemple #15
0
        int IComparable <KzUInt160> .CompareTo(KzUInt160 o)
        {
            var r = n2.CompareTo(o.n2);

            if (r == 0)
            {
                r = n1.CompareTo(o.n1);
            }
            if (r == 0)
            {
                r = n0.CompareTo(o.n0);
            }
            return(r);
        }
        /// <include file='doc\UInt64Storage.uex' path='docs/doc[@for="UInt64Storage.Compare"]/*' />
        /// <internalonly/>
        override public int Compare(int recordNo1, int recordNo2)
        {
            UInt64 valueNo1 = values[recordNo1];
            UInt64 valueNo2 = values[recordNo2];

            if (valueNo1.Equals(defaultValue) || valueNo2.Equals(defaultValue))
            {
                int bitCheck = CompareBits(recordNo1, recordNo2);
                if (0 != bitCheck)
                {
                    return(bitCheck);
                }
            }
            return(valueNo1.CompareTo(valueNo2));
        }
Exemple #17
0
        public int CompareTo(Object other)
        {
            if (other is UUID == false)
            {
                throw new CommonException("Object is not UUID");
            }

            int result;

            if ((result = m_FirstUInt64.CompareTo(((UUID)other).m_FirstUInt64)) == 0)
            {
                result = m_SecondUInt64.CompareTo(((UUID)other).m_SecondUInt64);
            }

            return(result);
        }
Exemple #18
0
        public virtual int CompareTo(object obj)
        {
            IOptimizedPersistable otherPersistentObject = obj as IOptimizedPersistable;

            if (otherPersistentObject != null)
            {
                if (otherPersistentObject.Id == 0 || m_id == 0)
                {
                    throw new PersistedObjectExcpectedException("When comparing IOptimizedPersistable objects, both objects must first be persisted (have a non 0 Id)");
                }
                return(m_id.CompareTo(otherPersistentObject.Id));
            }
            else
            {
                throw new ArgumentException("Object is not a IOptimizedPersistable");
            }
        }
Exemple #19
0
    public static void TestCompareTo()
    {
        UInt64 i = 234;

        Assert.Equal(0, i.CompareTo((UInt64)234));

        Assert.True(i.CompareTo(UInt64.MinValue) > 0);
        Assert.True(i.CompareTo((UInt64)0) > 0);
        Assert.True(i.CompareTo((UInt64)123) > 0);
        Assert.True(i.CompareTo((UInt64)456) < 0);
        Assert.True(i.CompareTo(UInt64.MaxValue) < 0);
    }
        public int CompareTo(IndexEntry other)
        {
            var keyCmp = Stream.CompareTo(other.Stream);

            if (keyCmp == 0)
            {
                keyCmp = Version.CompareTo(other.Version);
                if (keyCmp != 0)
                {
                    return(keyCmp);
                }
            }
            if (keyCmp != 0)
            {
                return(keyCmp);
            }
            return(Position.CompareTo(other.Position));
        }
Exemple #21
0
        public int CompareTo(KzUInt256 o)
        {
            var r = n3.CompareTo(o.n3);

            if (r == 0)
            {
                r = n2.CompareTo(o.n2);
            }
            if (r == 0)
            {
                r = n1.CompareTo(o.n1);
            }
            if (r == 0)
            {
                r = n0.CompareTo(o.n0);
            }
            return(r);
        }
Exemple #22
0
        public override int CompareValueTo(int recordNo, object value)
        {
            System.Diagnostics.Debug.Assert(0 <= recordNo, "Invalid record");
            System.Diagnostics.Debug.Assert(null != value, "null value");

            if (NullValue == value)
            {
                return(HasValue(recordNo) ? 1 : 0);
            }

            UInt64 valueNo1 = values[recordNo];

            if ((defaultValue == valueNo1) && !HasValue(recordNo))
            {
                return(-1);
            }
            return(valueNo1.CompareTo((UInt64)value));
            //return(valueNo1 < valueNo2 ? -1 : (valueNo1 > valueNo2 ? 1 : 0)); // similar to UInt64.CompareTo(UInt64)
        }
        /// <include file='doc\UInt64Storage.uex' path='docs/doc[@for="UInt64Storage.CompareToValue"]/*' />
        /// <internalonly/>
        override public int CompareToValue(int recordNo, Object value)
        {
            bool recordNull = IsNull(recordNo);

            if (recordNull && value == DBNull.Value)
            {
                return(0);
            }
            if (recordNull)
            {
                return(-1);
            }
            if (value == DBNull.Value)
            {
                return(1);
            }

            UInt64 valueNo1 = values[recordNo];
            UInt64 valueNo2 = Convert.ToUInt64(value);

            return(valueNo1.CompareTo(valueNo2));
        }
Exemple #24
0
        public int CompareTo(object obj)
        {
            AgentID rhs = (AgentID)obj;

            return(s.CompareTo(rhs.s));
        }
Exemple #25
0
 /// <summary>Compares this instance with a specified time stamp and indicates
 /// whether this instance precedes, follows, or appears in the same position
 /// in the sort order as the specified time stamp.
 /// </summary>
 /// <param name="other">
 /// The time stamp to compare with this instance.
 /// </param>
 /// <returns>
 /// A 32-bit signed integer that indicates whether this instance precedes, follows,
 /// or appears in the same position in the sort order as the value parameter.
 /// </returns>
 public int CompareTo(Timestamp other)
 {
     return(m_Value.CompareTo(other.m_Value));
 }
Exemple #26
0
    public static void Main()
    {
        string nl  = Environment.NewLine;
        string msg = "{0}The following is the result of using the generic and non-generic{0}" +
                     "versions of the CompareTo method for several base types:{0}";

        DateTime now = DateTime.Now;
// Time span = 11 days, 22 hours, 33 minutes, 44 seconds
        TimeSpan tsX = new TimeSpan(11, 22, 33, 44);
// Version = 1.2.333.4
        Version versX = new Version("1.2.333.4");
// Guid = CA761232-ED42-11CE-BACD-00AA0057B223
        Guid guidX = new Guid("{CA761232-ED42-11CE-BACD-00AA0057B223}");

        Boolean  a1 = true, a2 = true;
        Byte     b1 = 1, b2 = 1;
        Int16    c1 = -2, c2 = 2;
        Int32    d1 = 3, d2 = 3;
        Int64    e1 = 4, e2 = -4;
        Decimal  f1 = -5.5m, f2 = 5.5m;
        Single   g1 = 6.6f, g2 = 6.6f;
        Double   h1 = 7.7d, h2 = -7.7d;
        Char     i1 = 'A', i2 = 'A';
        String   j1 = "abc", j2 = "abc";
        DateTime k1 = now, k2 = now;
        TimeSpan l1 = tsX, l2 = tsX;
        Version  m1 = versX, m2 = new Version("2.0");
        Guid     n1 = guidX, n2 = guidX;

// The following types are not CLS-compliant.
        SByte  w1 = 8, w2 = 8;
        UInt16 x1 = 9, x2 = 9;
        UInt32 y1 = 10, y2 = 10;
        UInt64 z1 = 11, z2 = 11;

//
        Console.WriteLine(msg, nl);
        try
        {
// The second and third Show method call parameters are automatically boxed because
// the second and third Show method declaration arguments expect type Object.

            Show("Boolean:  ", a1, a2, a1.CompareTo(a2), a1.CompareTo((Object)a2));
            Show("Byte:     ", b1, b2, b1.CompareTo(b2), b1.CompareTo((Object)b2));
            Show("Int16:    ", c1, c2, c1.CompareTo(c2), c1.CompareTo((Object)c2));
            Show("Int32:    ", d1, d2, d1.CompareTo(d2), d1.CompareTo((Object)d2));
            Show("Int64:    ", e1, e2, e1.CompareTo(e2), e1.CompareTo((Object)e2));
            Show("Decimal:  ", f1, f2, f1.CompareTo(f2), f1.CompareTo((Object)f2));
            Show("Single:   ", g1, g2, g1.CompareTo(g2), g1.CompareTo((Object)g2));
            Show("Double:   ", h1, h2, h1.CompareTo(h2), h1.CompareTo((Object)h2));
            Show("Char:     ", i1, i2, i1.CompareTo(i2), i1.CompareTo((Object)i2));
            Show("String:   ", j1, j2, j1.CompareTo(j2), j1.CompareTo((Object)j2));
            Show("DateTime: ", k1, k2, k1.CompareTo(k2), k1.CompareTo((Object)k2));
            Show("TimeSpan: ", l1, l2, l1.CompareTo(l2), l1.CompareTo((Object)l2));
            Show("Version:  ", m1, m2, m1.CompareTo(m2), m1.CompareTo((Object)m2));
            Show("Guid:     ", n1, n2, n1.CompareTo(n2), n1.CompareTo((Object)n2));
//
            Console.WriteLine("{0}The following types are not CLS-compliant:", nl);
            Show("SByte:    ", w1, w2, w1.CompareTo(w2), w1.CompareTo((Object)w2));
            Show("UInt16:   ", x1, x2, x1.CompareTo(x2), x1.CompareTo((Object)x2));
            Show("UInt32:   ", y1, y2, y1.CompareTo(y2), y1.CompareTo((Object)y2));
            Show("UInt64:   ", z1, z2, z1.CompareTo(z2), z1.CompareTo((Object)z2));
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }
Exemple #27
0
    public Boolean runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " ,for " + s_strComponentBeingTested + "  ,Source ver " + s_strDtTmVer);
        String strBaseLoc;

        try
        {
            m_strLoc = "Loc_normalTests";
            UInt64 primitiveULong = 100;
            UInt64 testUIntOne    = ((UInt64)primitiveULong);
            UInt64 testUIntTwo    = ((UInt64)2 * primitiveULong);
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to self";
                if (testUIntOne.CompareTo(testUIntOne) != 0)
                {
                    ErrorCode();
                }
            } catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to lesser";
                if (testUIntTwo.CompareTo(testUIntOne) < 0)
                {
                    ErrorCode();
                }
            } catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to lesser";
                if (testUIntTwo.CompareTo(testUIntOne) < 0)
                {
                    ErrorCode();
                }
            } catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("testUIntOne = " + testUIntOne);
                Console.WriteLine("testUIntTwo = " + testUIntTwo);
                Console.WriteLine("two.CompareTo( one ) = " + testUIntTwo.CompareTo(testUIntOne));
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to greater";
                if (testUIntOne.CompareTo(testUIntTwo) > 0)
                {
                    ErrorCode();
                }
            } catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to greater";
                if (testUIntOne.CompareTo(testUIntTwo) > 0)
                {
                    ErrorCode();
                }
            } catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to String";
                testUIntOne.CompareTo("Throw Something");
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("No Exception thrown");
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            catch (ArgumentException e) {}
            catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "] -- Wrong Exception!");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to Int16";
                testUIntOne.CompareTo(((Int16)12));
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("No Exception thrown");
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            catch (ArgumentException e) {}
            catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "] -- Wrong Exception!");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to primitive UInt64";
                UInt16 pInt = 100;
                if (testUIntOne.CompareTo(pInt) != 0)
                {
                    ErrorCode();
                }
            }
            catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "] -- Wrong Exception!");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to primitive UInt64";
                if (testUIntOne.CompareTo(primitiveULong) != 0)
                {
                    ErrorCode();
                }
            }
            catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "] -- Wrong Exception!");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            iCountTestcases++;
            try {
                m_strLoc = "Starting testcase #" + iCountTestcases;
                m_strLoc = m_strLoc + "Compare to primitive short";
                short pShort = 100;
                testUIntOne.CompareTo(pShort);
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "]");
                Console.WriteLine("No Exception thrown");
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
            catch (ArgumentException e) {}
            catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Testcase[" + iCountTestcases + "] -- Wrong Exception!");
                Console.WriteLine("Exception:" + e);
                Console.WriteLine("StrLoc = '" + m_strLoc + "'");
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine("Error Err_8888yyy (" + s_strTFAbbrev + ")!  Unexpected exception thrown sometime after m_strLoc==" + m_strLoc + " ,exc_general==" + exc_general);
        }
        Console.Write(Environment.NewLine);
        Console.WriteLine("Total Tests Ran: " + iCountTestcases + " Failed Tests: " + iCountErrors);
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + "  ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + "  ,iCountErrors==" + iCountErrors + " ,BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Exemple #28
0
 /// <summary>
 ///     A T extension method that check if the value is between inclusively the minValue and maxValue.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="minValue">The minimum value.</param>
 /// <param name="maxValue">The maximum value.</param>
 /// <returns>true if the value is between inclusively the minValue and maxValue, otherwise false.</returns>
 /// ###
 /// <typeparam name="T">Generic type parameter.</typeparam>
 public static bool InRange(this UInt64 @this, UInt64 minValue, UInt64 maxValue)
 {
     return(@this.CompareTo(minValue) >= 0 && @this.CompareTo(maxValue) <= 0);
 }
 private static void Compare_UInt64(UInt64 a, UInt64 b) =>
 AssertEquals(a.CompareTo(b), Comparer <UInt64> .Default.Compare(a, b));
Exemple #30
0
 /// <summary>
 ///     A T extension method that check if the value is between (exclusif) the minValue and maxValue.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="minValue">The minimum value.</param>
 /// <param name="maxValue">The maximum value.</param>
 /// <returns>true if the value is between the minValue and maxValue, otherwise false.</returns>
 /// ###
 /// <typeparam name="T">Generic type parameter.</typeparam>
 public static bool Between(this UInt64 @this, UInt64 minValue, UInt64 maxValue)
 {
     return(minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1);
 }