public void TestEquals() { Assert.IsTrue(MyUInt64_1.Equals(MyUInt64_1)); Assert.IsTrue(MyUInt64_1.Equals((object)(UInt64)(42))); Assert.IsTrue(MyUInt64_1.Equals((object)(SByte)(42)) == false); Assert.IsTrue(MyUInt64_1.Equals(MyUInt64_2) == false); }
public static void TestEquals() { UInt64 i = 911; Assert.True(i.Equals((UInt64)911)); Assert.True(!i.Equals((UInt64)0)); }
public override bool Equals(object obj) { var asrealmkey = obj as RealmMapKey; if (asrealmkey != null) { return(_key.Equals(asrealmkey._key)); } return(_key.Equals(obj)); }
public static void TestEqualsObject() { UInt64 i = 789; object obj1 = (UInt64)789; Assert.True(i.Equals(obj1)); object obj3 = (UInt64)0; Assert.True(!i.Equals(obj3)); }
private static bool VerifyUInt64ImplicitCastToBigInteger(UInt64 value) { bool ret = true; BigInteger bigInteger; bigInteger = value; ret &= Eval(bigInteger.Equals(value), String.Format("Expected BigInteger {0} to be equal to UInt64 {1}", bigInteger, value)); ret &= Eval(value.ToString(), bigInteger.ToString(), "UInt64.ToString() and BigInteger.ToString()"); ret &= Eval(value, (UInt64)bigInteger, "Round tripped UInt64"); if (value != UInt64.MaxValue) { ret &= Eval((UInt64)(value + 1), (UInt64)(bigInteger + 1), "BigInteger added to 1"); } if (value != UInt64.MinValue) { ret &= Eval((UInt64)(value - 1), (UInt64)(bigInteger - 1), "BigInteger subtracted by 1"); } ret &= VerifyBigintegerUsingIdentities(bigInteger, 0 == value); return(ret); }
/// <summary> /// Compares two reservation identifications for equality. /// </summary> /// <param name="ReservationId">An reservation identification to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(Reservation_Id ReservationId) { if ((Object)ReservationId == null) { return(false); } return(_Value.Equals(ReservationId._Value)); }
/// <summary> /// Compares two transaction identifications for equality. /// </summary> /// <param name="TransactionId">An transaction identification to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(Transaction_Id TransactionId) { if ((Object)TransactionId == null) { return(false); } return(_Value.Equals(TransactionId._Value)); }
/// <summary> /// Compares two charging profile identifications for equality. /// </summary> /// <param name="ChargingProfileId">An charging profile identification to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(ChargingProfile_Id ChargingProfileId) { if ((Object)ChargingProfileId == null) { return(false); } return(_Value.Equals(ChargingProfileId._Value)); }
/// <summary> /// Compares two EVSE identifications for equality. /// </summary> /// <param name="EVSEId">An EVSE identification to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(EVSE_Id EVSEId) { if ((Object)EVSEId == null) { return(false); } return(_Value.Equals(EVSEId._Value)); }
/// <summary> /// Compares two connector identifications for equality. /// </summary> /// <param name="ConnectorId">An connector identification to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(Connector_Id ConnectorId) { if ((Object) ConnectorId == null) return false; return _Value.Equals(ConnectorId._Value); }
/// <summary> /// Compares two connector identifications for equality. /// </summary> /// <param name="ConnectorId">An connector identification to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(Connector_Id ConnectorId) { if ((Object)ConnectorId == null) { return(false); } return(_Value.Equals(ConnectorId._Value)); }
/// <include file='doc\UInt64Storage.uex' path='docs/doc[@for="UInt64Storage.Get"]/*' /> /// <internalonly/> override public Object Get(int record) { UInt64 value = values[record]; if (!value.Equals(defaultValue)) { return(value); } return(GetBits(record)); }
/// <summary> /// Determines whether the specified <see cref="System.Object" /> is equal to this <see cref="SecsUInt64"/> instance. /// </summary> /// <param name="obj">The <see cref="System.Object" /> to compare with this <see cref="SecsUInt64"/> instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object" /> is equal to this <see cref="SecsUInt64"/> instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { if (obj == null || !(obj is SecsUInt64)) { return(false); } SecsUInt64 sobj = obj as SecsUInt64; return(_value.Equals(sobj._value)); }
public override bool Equals(object obj) { var other = obj as HashKey; if (other == null) { return(false); } return(Type.Equals(other.Type) && Value.Equals(other.Value)); }
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); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (!(obj is Item)) { return(false); } Item other = (Item)obj; return((other._ulong == _ulong) && _ulongWrapper.Equals(other._ulongWrapper)); }
/// <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)); }
public static void Main() { UInt64 value1 = 50; UInt64 value2 = 50; // Display the values. Console.WriteLine("value1: Type: {0} Value: {1}", value1.GetType().Name, value1); Console.WriteLine("value2: Type: {0} Value: {1}", value2.GetType().Name, value2); // Compare the two values. Console.WriteLine("value1 and value2 are equal: {0}", value1.Equals(value2)); }
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); return(valueNo1 < valueNo2 ? -1 : (valueNo1 > valueNo2 ? 1 : 0)); // similar to UInt64.CompareTo(UInt64) }
public static void Main() { object[] values = { (short)10, (short)20, 10, 20, 10L, 20L, 10D, 20D,(ushort)10, (ushort)20, 10U, 20U, 10ul, 20ul }; UInt64 baseValue = 20; String baseType = baseValue.GetType().Name; foreach (var value in values) { Console.WriteLine("{0} ({1}) = {2} ({3}): {4}", baseValue, baseType, value, value.GetType().Name, baseValue.Equals(value)); } }
public UInt64 GetNthPrime(UInt64 n) { UInt64 count = 0; for (UInt64 i = 2; i < UInt64.MaxValue; i++) { if (IsPrime(i)) { count++; if (count.Equals(n)) { return(i); } } } return(0); }
/// <summary> /// Adds an item in the Ecommerce order. /// /// This should be called before doTrackEcommerceOrder(), or before doTrackEcommerceCartUpdate(). /// This function can be called for all individual products in the cart (or order). /// SKU parameter is mandatory. Other parameters are optional (set to false if value not known). /// Ecommerce items added via this function are automatically cleared when doTrackEcommerceOrder() or getUrlTrackEcommerceOrder() is called. /// </summary> /// <param name="sku">SKU, Product identifier </param> /// <param name="name">Product name</param> /// <param name="category">Product category</param> /// <param name="price"> Individual product price (supports integer and decimal prices)</param> /// <param name="quantity">Product quantity. If not specified, will default to 1 in the Reports</param> public void addEcommerceItem(string sku, string name = null, string category = null, double price = Double.MinValue, UInt64 quantity = UInt64.MinValue) { if (String.IsNullOrEmpty(sku)) { throw new Exception("You must specify a SKU for the Ecommerce item"); } string sanitizedName = name; if (name == null) { sanitizedName = "false"; } string sanitizedCategory = category; if (category == null) { sanitizedCategory = "false"; } string priceString = formatMonetaryValue(price); if (price.Equals(Double.MinValue)) { priceString = "false"; } string quantityString = quantity.ToString(); if (quantity.Equals(UInt64.MinValue)) { quantityString = "false"; } string[] eCommerceItem = { sku, sanitizedName, sanitizedCategory, priceString, quantityString }; ecommerceItems.Remove(sku); ecommerceItems.Add(sku, eCommerceItem); }
public Boolean runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " ,for " + s_strClassMethod + " ,Source ver " + s_strDtTmVer); String strLoc = "Loc_000oo"; int iCountTestcases = 0; int iCountErrors = 0; printoutCoveredMethods(); if (verbose) { Console.WriteLine("Testing Method: Boolean"); } try { Boolean[] testValues = { true, false, }; UInt64[] expectedValues = { ((UInt64)1), ((UInt64)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vboolAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xboolAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Boolean )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: Double"); } try { Double[] testValues = { 1000.0, 0.0, }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vdoubAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xdoubAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", "System.OverflowException", }; Double[] errorValues = { Double.MaxValue, -100.0, }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i]); iCountErrors++; strLoc = "Err_EXdoubArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXdoubArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Double )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: Single"); } try { Single[] testValues = { ((Single)1000.0f), ((Single)0.0f), }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vsingAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xsingAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", "System.OverflowException", }; Single[] errorValues = { Single.MaxValue, -100.0f, }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i]); iCountErrors++; strLoc = "Err_EXsingArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXsingArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Single )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: Int32"); } try { Int32[] testValues = { ((Int32)1000), ((Int32)0), Int32.MaxValue, }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), ((UInt64)Int32.MaxValue), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vint3Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xint3Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", }; Int32[] errorValues = { ((Int32)Int32.MinValue), }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i]); iCountErrors++; strLoc = "Err_EXint3ArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXint3ArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Int32 )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: Int64"); } try { Int64[] testValues = { ((Int64)1000), ((Int64)0), Int64.MaxValue, }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), ((IConvertible)(Int64.MaxValue)).ToUInt64(null), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vint6Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xint6Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Int64 )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: Int16"); } try { Int16[] testValues = { ((Int16)1000), ((Int16)0), Int16.MaxValue, }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), ((UInt64)(UInt64)Int16.MaxValue), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vint1Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xint1Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", }; Int16[] errorValues = { Int16.MinValue, }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i]); iCountErrors++; strLoc = "Err_EXint1ArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXint1ArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Int16 )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: Decimal"); } try { Decimal[] testValues = { new Decimal(1000), new Decimal(0), }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vdeciAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xdeciAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", "System.OverflowException", }; Decimal[] errorValues = { Decimal.MaxValue, Decimal.MinValue, }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i]); iCountErrors++; strLoc = "Err_EXdeciArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXdeciArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Decimal )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: String"); } try { String[] testValues = { "1000", "0", UInt16.MaxValue.ToString(), UInt32.MaxValue.ToString(), UInt64.MaxValue.ToString(), null, }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), Convert.ToUInt64(UInt16.MaxValue), Convert.ToUInt64(UInt32.MaxValue), UInt64.MaxValue, 0, }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vstriAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xstriAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", "System.OverflowException", "System.FormatException", }; String[] errorValues = { "-1", Decimal.MaxValue.ToString(), "abba", }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i]); iCountErrors++; strLoc = "Err_EXstriArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXstriArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( String )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: String"); } try { String[] testValues = { "1000", "0", UInt16.MaxValue.ToString(), UInt32.MaxValue.ToString(), UInt64.MaxValue.ToString(), null, }; UInt64[] expectedValues = { ((UInt64)1000), ((UInt64)0), Convert.ToUInt64(UInt16.MaxValue), Convert.ToUInt64(UInt32.MaxValue), UInt64.MaxValue, ((UInt64)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i], new NumberFormatInfo()); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vstriAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xstriAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", "System.OverflowException", "System.FormatException", }; String[] errorValues = { "-1", Decimal.MaxValue.ToString(), "abba", }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i], new NumberFormatInfo()); iCountErrors++; strLoc = "Err_EXstriArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXstriArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( String )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: Byte"); } try { Byte[] testValues = { Byte.MaxValue, Byte.MinValue, }; UInt64[] expectedValues = { ((UInt32)255), ((UInt32)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vSByteAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xSByteAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( Byte )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: UInt32"); } try { UInt32[] testValues = { UInt32.MinValue, UInt32.MaxValue, }; UInt64[] expectedValues = { UInt32.MinValue, UInt32.MaxValue, }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vUInt32Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xUInt32Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } } catch (Exception e) { Console.WriteLine("Uncaught Exception in UInt64 Convert.ToUInt64( UInt32 )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: String, Int32"); } try { String [] dummy = { null, }; UInt64 result = Convert.ToUInt64(dummy[0], 10); if (result != 0) { iCountErrors++; strLoc = "Err_xstri2A1"; Console.Error.WriteLine(strLoc + " No Exception Thrown."); } result = Convert.ToUInt64(dummy[0], 2); if (result != 0) { iCountErrors++; strLoc = "Err_xstri2A1"; Console.Error.WriteLine(strLoc + " No Exception Thrown."); } result = Convert.ToUInt64(dummy[0], 8); if (result != 0) { iCountErrors++; strLoc = "Err_xstri2A1"; Console.Error.WriteLine(strLoc + " No Exception Thrown."); } result = Convert.ToUInt64(dummy[0], 16); if (result != 0) { iCountErrors++; strLoc = "Err_xstri2A1"; Console.Error.WriteLine(strLoc + " No Exception Thrown."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xstri2C1"; Console.Error.WriteLine(strLoc + " Wrong Exception Thrown: " + e.GetType().FullName); } try { String[] testValues = { "ffffffffffffffff", "18446744073709551615", "1777777777777777777777", "1111111111111111111111111111111111111111111111111111111111111111", "0", "0", "0", "0", }; Int32[] testBases = { 16, 10, 8, 2, 16, 10, 8, 2, }; UInt64[] expectedValues = { UInt64.MaxValue, UInt64.MaxValue, UInt64.MaxValue, UInt64.MaxValue, UInt64.MinValue, UInt64.MinValue, UInt64.MinValue, UInt64.MinValue, }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i], testBases[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vstr2Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xstr2Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.FormatException", "System.ArgumentException", "System.ArgumentException", "System.FormatException", }; String[] errorValues = { "12", "11", "abba", "ffffffffffffffffffff" }; Int32[] errorBases = { 2, 3, 5, 8, 16, }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i], errorBases[i]); iCountErrors++; strLoc = "Err_EXstr2ArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXstr2ArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { iCountErrors++; Console.WriteLine("Error_98934! Uncaught Exception in UInt64 Convert.ToUInt64( str2int )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: SByte"); } try { SByte[] testValues = { 100, 0, }; UInt64[] expectedValues = { ((UInt64)100), ((UInt64)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vint8Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xint8Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } String[] expectedExceptions = { "System.OverflowException", }; SByte[] errorValues = { SByte.MinValue }; for (int i = 0; i < expectedExceptions.Length; i++) { iCountTestcases++; try { if (verbose) { Console.WriteLine(" Exception Testing: " + expectedExceptions[i]); } UInt64 result = Convert.ToUInt64(errorValues[i]); iCountErrors++; strLoc = "Err_EXint3ArNoE," + i; Console.WriteLine(strLoc + " Exception not Thrown!"); } catch (Exception e) { if (!e.GetType().FullName.Equals(expectedExceptions[i])) { iCountErrors++; strLoc = "Err_EXint3ArWrE," + i; Console.WriteLine(strLoc + " Wrong Exception Thrown " + e.GetType().FullName); } } } } catch (Exception e) { iCountErrors++; Console.WriteLine("Error_433jk! Uncaught Exception in UInt64 Convert.ToUInt64( SByte )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: UInt16"); } try { UInt16[] testValues = { (UInt16)100, (UInt16)0, }; UInt64[] expectedValues = { ((UInt64)100), ((UInt64)0), }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vUInt16Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xUInt16Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } } catch (Exception e) { iCountErrors++; Console.WriteLine("Error_988yd! Uncaught Exception in UInt64 Convert.ToUInt64( Int16 )"); Console.WriteLine("Exception->" + e.GetType().FullName); } if (verbose) { Console.WriteLine("Testing Method: UInt64"); } try { UInt64[] testValues = { UInt64.MaxValue, UInt64.MinValue }; UInt64[] expectedValues = { UInt64.MaxValue, UInt64.MinValue }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vUInt64Ar," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xUInt64Ar," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } } catch (Exception e) { iCountErrors++; Console.WriteLine("Error_4789y! Uncaught Exception in Byte Convert.ToUInt64( UInt64 )"); Console.WriteLine("Exception->" + e.GetType().ToString()); } if (verbose) { Console.WriteLine("Testing Method: Char"); } try { Char[] testValues = { Char.MaxValue, Char.MinValue, 'b' }; UInt64[] expectedValues = { (UInt64)Char.MaxValue, (UInt64)Char.MinValue, 98 }; for (int i = 0; i < testValues.Length; i++) { iCountTestcases++; if (verbose) { Console.Write("Testing " + testValues[i] + " ==> "); } try { UInt64 result = Convert.ToUInt64(testValues[i]); if (verbose) { Console.WriteLine("'" + expectedValues[i] + "' == '" + result + "'"); } if (!result.Equals(expectedValues[i])) { iCountErrors++; strLoc = "Err_vcharAr," + i; Console.Error.WriteLine(strLoc + " Expected = '" + expectedValues[i] + "' ... Received = '" + result + "'."); } } catch (Exception e) { iCountErrors++; strLoc = "Err_xcharAr," + i; Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } } } catch (Exception e) { iCountErrors++; Console.WriteLine("Error_4789y! Uncaught Exception in UInt64 Convert.ToUInt64( Char )"); Console.WriteLine("Exception->" + e.GetType().FullName); } strLoc = "Err_dew452,"; try { iCountTestcases++; UInt64 bTest = Convert.ToUInt64(new Object()); Console.Error.WriteLine(strLoc + " No Exception Thrown"); } catch (InvalidCastException) {} catch (Exception e) { Console.WriteLine(e.ToString()); Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } strLoc = "Err_dew452,"; try { iCountTestcases++; UInt64 bTest = Convert.ToUInt64(new Object(), new NumberFormatInfo()); Console.Error.WriteLine(strLoc + " No Exception Thrown"); } catch (InvalidCastException) {} catch (Exception e) { Console.WriteLine(e.ToString()); Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } strLoc = "Err_dew452,"; try { iCountTestcases++; UInt64 bTest = Convert.ToUInt64(DateTime.Now); Console.Error.WriteLine(strLoc + " No Exception Thrown"); } catch (InvalidCastException) {} catch (Exception e) { Console.WriteLine(e.ToString()); Console.Error.WriteLine(strLoc + " Exception Thrown: " + e.GetType().FullName); } Console.Error.Write(s_strTFName); Console.Error.Write(": "); if (iCountErrors == 0) { Console.Error.WriteLine(" iCountTestcases==" + iCountTestcases + " paSs"); return(true); } else { Console.Error.WriteLine(s_strTFPath + s_strTFName + ".cs"); Console.Error.WriteLine(" iCountTestcases==" + iCountTestcases); Console.Error.WriteLine("FAiL"); Console.Error.WriteLine(" iCountErrors==" + iCountErrors); return(false); } }
private void button3_Click(object sender, EventArgs e) { // Update Core.Output("Updating results, showing only ones with new value..."); string val = textBox1.Text; string type = comboBox1.Text; if (type == "Int16") { } else if (type == "Int32") { Int32 value = Int32.Parse(val); BindingSource s = (BindingSource)dataGridView1.DataSource; List <Tuple <IntPtr, Int32> > data = (List <Tuple <IntPtr, Int32> >)s.DataSource; List <Tuple <IntPtr, Int32> > newdata = new List <Tuple <IntPtr, Int32> >(); foreach (Tuple <IntPtr, Int32> t in data) { Int32 nval = MM.ReadInt32(t.Item1); if (nval.Equals(value)) { newdata.Add(new Tuple <IntPtr, Int32>(t.Item1, nval)); } } s.DataSource = newdata; dataGridView1.DataSource = s; } else if (type == "UInt32") { UInt32 value = UInt32.Parse(val); BindingSource s = (BindingSource)dataGridView1.DataSource; List <Tuple <IntPtr, UInt32> > data = (List <Tuple <IntPtr, UInt32> >)s.DataSource; List <Tuple <IntPtr, UInt32> > newdata = new List <Tuple <IntPtr, UInt32> >(); foreach (Tuple <IntPtr, UInt32> t in data) { UInt32 nval = MM.ReadUInt32(t.Item1); if (nval.Equals(value)) { newdata.Add(new Tuple <IntPtr, UInt32>(t.Item1, nval)); } } s.DataSource = newdata; dataGridView1.DataSource = s; } else if (type == "Int64") { Int64 value = Int64.Parse(val); BindingSource s = (BindingSource)dataGridView1.DataSource; List <Tuple <IntPtr, Int64> > data = (List <Tuple <IntPtr, Int64> >)s.DataSource; List <Tuple <IntPtr, Int64> > newdata = new List <Tuple <IntPtr, Int64> >(); foreach (Tuple <IntPtr, Int64> t in data) { Int64 nval = MM.ReadInt64(t.Item1); if (nval.Equals(value)) { newdata.Add(new Tuple <IntPtr, Int64>(t.Item1, nval)); } } s.DataSource = newdata; dataGridView1.DataSource = s; } else if (type == "UInt64") { UInt64 value = UInt64.Parse(val); BindingSource s = (BindingSource)dataGridView1.DataSource; List <Tuple <IntPtr, UInt64> > data = (List <Tuple <IntPtr, UInt64> >)s.DataSource; List <Tuple <IntPtr, UInt64> > newdata = new List <Tuple <IntPtr, UInt64> >(); foreach (Tuple <IntPtr, UInt64> t in data) { UInt64 nval = MM.ReadUInt64(t.Item1); if (nval.Equals(value)) { newdata.Add(new Tuple <IntPtr, UInt64>(t.Item1, nval)); } } s.DataSource = newdata; dataGridView1.DataSource = s; } else if (type == "Float") { float value = float.Parse(val); BindingSource s = (BindingSource)dataGridView1.DataSource; List <Tuple <IntPtr, float> > data = (List <Tuple <IntPtr, float> >)s.DataSource; List <Tuple <IntPtr, float> > newdata = new List <Tuple <IntPtr, float> >(); foreach (Tuple <IntPtr, float> t in data) { float nval = MM.ReadFloat(t.Item1); if (nval.Equals(value)) { newdata.Add(new Tuple <IntPtr, float>(t.Item1, nval)); } } s.DataSource = newdata; dataGridView1.DataSource = s; } else if (type == "Double") { double value = double.Parse(val); BindingSource s = (BindingSource)dataGridView1.DataSource; List <Tuple <IntPtr, double> > data = (List <Tuple <IntPtr, double> >)s.DataSource; List <Tuple <IntPtr, double> > newdata = new List <Tuple <IntPtr, double> >(); foreach (Tuple <IntPtr, double> t in data) { double nval = MM.ReadDouble(t.Item1); if (nval.Equals(value)) { newdata.Add(new Tuple <IntPtr, double>(t.Item1, nval)); } } s.DataSource = newdata; dataGridView1.DataSource = s; } }
public override bool Equals(object obj) { return(_value.Equals(obj)); }
public void BalancedEncodeDecodeUInt32NET() { var modulus = new SmallModulus(0x10000); var encoder = new BalancedEncoder(modulus, 3, MemoryPoolHandle.New()); var poly = encoder.Encode(0U); Assert.AreEqual(0, poly.SignificantCoeffCount()); Assert.IsTrue(poly.IsZero); Assert.AreEqual(0U, encoder.DecodeUInt32(poly)); var poly1 = encoder.Encode(1U); Assert.AreEqual(1, poly1.SignificantCoeffCount()); Assert.AreEqual("1", poly1.ToString()); Assert.AreEqual(1U, encoder.DecodeUInt32(poly1)); var poly2 = encoder.Encode(2U); Assert.AreEqual(2, poly2.SignificantCoeffCount()); Assert.AreEqual("1x^1 + FFFF", poly2.ToString()); Assert.AreEqual(2U, encoder.DecodeUInt32(poly2)); var poly3 = encoder.Encode(3U); Assert.AreEqual(2, poly3.SignificantCoeffCount()); Assert.AreEqual("1x^1", poly3.ToString()); Assert.AreEqual(3U, encoder.DecodeUInt32(poly3)); var poly4 = encoder.Encode(0x2671U); Assert.AreEqual(9, poly4.SignificantCoeffCount()); for (int i = 0; i < 9; ++i) { Assert.AreEqual(1UL, poly4[i]); } Assert.AreEqual(0x2671U, encoder.DecodeUInt32(poly4)); var poly5 = encoder.Encode(0xD4EBU); Assert.AreEqual(11, poly5.SignificantCoeffCount()); for (int i = 0; i < 11; ++i) { if (i % 3 == 1) { Assert.AreEqual(1UL, poly5[i]); } else if (i % 3 == 0) { Assert.IsTrue(poly5[i] == 0); } else { Assert.AreEqual(0xFFFFUL, poly5[i]); } } Assert.AreEqual(0xD4EBU, encoder.DecodeUInt32(poly5)); var poly6 = new Plaintext(3); poly6[0] = 1; poly6[1] = 500; poly6[2] = 1023; Assert.AreEqual(1U + 500 * 3 + 1023 * 9, encoder.DecodeUInt32(poly6)); var encoder2 = new BalancedEncoder(modulus, 7, MemoryPoolHandle.New()); var poly7 = new Plaintext(4); poly7[0] = 123; // 123 (*1) poly7[1] = 0xFFFF; // -1 (*7) poly7[2] = 511; // 511 (*49) poly7[3] = 1; // 1 (*343) Assert.AreEqual((UInt32)(123 + -1 * 7 + 511 * 49 + 1 * 343), encoder2.DecodeUInt32(poly7)); var encoder3 = new BalancedEncoder(modulus, 6, MemoryPoolHandle.New()); var poly8 = new Plaintext(4); poly8[0] = 5; poly8[1] = 4; poly8[2] = 3; poly8[3] = 2; UInt64 value = 5 + 4 * 6 + 3 * 36 + 2 * 216; Assert.AreEqual(value, encoder3.DecodeUInt32(poly8)); var encoder4 = new BalancedEncoder(modulus, 10, MemoryPoolHandle.New()); var poly9 = new Plaintext(4); poly9[0] = 1; poly9[1] = 2; poly9[2] = 3; poly9[3] = 4; value = 4321; Assert.AreEqual(value, encoder4.DecodeUInt32(poly9)); value = 1234; var poly10 = encoder2.Encode(value); Assert.AreEqual(5, poly10.SignificantCoeffCount()); Assert.IsTrue(value.Equals(encoder2.DecodeUInt32(poly10))); value = 1234; var poly11 = encoder3.Encode(value); Assert.AreEqual(5, poly11.SignificantCoeffCount()); Assert.IsTrue(value.Equals(encoder3.DecodeUInt32(poly11))); value = 1234; var poly12 = encoder4.Encode(value); Assert.AreEqual(4, poly12.SignificantCoeffCount()); Assert.IsTrue(value.Equals(encoder4.DecodeUInt32(poly12))); }
/*********************************************************************** * * @method: FileShredderThread * @param: arg : object - Array / struct data passed to the thread containing everything it needs * @notes: The heart of the beast * ************************************************************************/ void FileShredderThread(object arg) { int file_index = 0; UInt64 total_data_written = 0; UInt64 total_bytes_shredded = 0; ArrayList arg_list = (ArrayList)arg; ArrayList files = (ArrayList)arg_list[(int)ThreadArgs.FILES]; UInt64 mode = Convert.ToUInt64(arg_list[(int)ThreadArgs.MODE]); UInt64 passes = Convert.ToUInt64(arg_list[(int)ThreadArgs.PASSES]); UInt64 buf_size = Convert.ToUInt64(arg_list[(int)ThreadArgs.BUFFER_SIZE]); UInt64 total_data_to_write = Convert.ToUInt64(arg_list[(int)ThreadArgs.TOTAL_SIZE]); total_data_to_write *= passes; DateTime StartTime = DateTime.Now; foreach (string file in files) { UInt64 amount_written_to_current_element = 0; try { FileInfo fi = new FileInfo(file); if (fi.Exists) { for (UInt32 i_pass = 1; i_pass <= passes; i_pass++) { UInt64 file_length = (UInt64)fi.Length; total_bytes_shredded += file_length; FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Write); byte[] buff = new byte[buf_size]; if (file_length > buf_size) { UInt64 total_iterations = file_length / buf_size; UInt32 current_iteration = 0; for (; current_iteration <= total_iterations; current_iteration++) { total_data_written += buf_size; amount_written_to_current_element += buf_size; if (current_iteration % 10 == 0) //at 65kb per iteration, updated every 650kb { UInt64 total_progress_percent = (total_data_written / total_data_to_write) * 100; UInt64 current_percent = (amount_written_to_current_element / ((UInt64)fi.Length * passes) * 100); UpdateMainPBar((int)total_progress_percent); UpdateLVPBar(file_index, (int)current_percent); } if (mode.Equals(0))//random data { RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider(); rngCsp.GetBytes(buff); } fs.Write(buff, 0, (int)buf_size); } } else //if( file_length <= buf_size ) { fs.Write(buff, 0, (int)buf_size); } fs.Flush(); fs.Close(); //UNCOMMENT THESE TO DELETE FILE if (i_pass.Equals(passes)) { fi.Delete(); } } } } catch (System.IO.IOException ioException) { MessageBox.Show("FileShredderThread " + ioException.Message.ToString()); } catch (Exception except) { MessageBox.Show("FileShredderThread " + except.Message.ToString()); } RemoveCompletedItemsMethod(file_index); file_index++; } CleaningComplete(total_bytes_shredded, StartTime); }
public Boolean runTest() { Console.WriteLine(s_strTFPath + " " + s_strTFName + " ,for " + s_strComponentBeingTested + " ,Source ver " + s_strDtTmVer); String strBaseLoc; try { m_strLoc = "Loc_normalTests"; UInt64 primativeULongA = 100; UInt64 primativeULongB = 200; UInt64 testUIntA = ((UInt64)primativeULongA); UInt64 testUIntAA = ((UInt64)primativeULongA); UInt64 testUIntB = ((UInt64)primativeULongB); iCountTestcases++; try { m_strLoc = "Starting testcase #" + iCountTestcases; m_strLoc = m_strLoc + "Equals self"; if (testUIntA.Equals(testUIntA) != true) { 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 + "Equals same value"; if (testUIntA.Equals(testUIntAA) != true) { 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 + "Equals diff value"; if (testUIntA.Equals(testUIntB) == true) { 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 + "Equals primative UInt64"; if (testUIntA.Equals(primativeULongA) != true) { 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 + "Equals string 100"; if (testUIntA.Equals("100") == true) { 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 + "Equals new UInt64 same val"; if (testUIntA.Equals(((UInt64)primativeULongA)) != true) { ErrorCode(); } } catch (Exception e) { iCountErrors++; Console.WriteLine("Testcase[" + iCountTestcases + "]"); 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); } }
public override bool Equals(ulong x, ulong y) { return(UInt64.Equals(x, y)); }