public bool PosTest4() { bool retVal = true; const string c_TEST_ID = "P004"; const string c_TEST_DESC = "PosTest4: UIntPtr vs UInt32"; string errorDesc; UIntPtr srcUIntPtr; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { UInt32 ui = (UInt32)TestLibrary.Generator.GetInt32(-55); srcUIntPtr = new UIntPtr(ui); actualResult = !srcUIntPtr.Equals(ui); if (!actualResult) { errorDesc = "UIntPtr " + srcUIntPtr + " should not equal UInt" + ui; TestLibrary.TestFramework.LogError("007" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("008" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return(retVal); }
public bool PosTest5() { bool retVal = true; const string c_TEST_ID = "P005"; const string c_TEST_DESC = "PosTest5: UIntPtr vs Object"; string errorDesc; UIntPtr srcUIntPtr; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { object obj = new object(); srcUIntPtr = new UIntPtr(); actualResult = !srcUIntPtr.Equals(obj); if (!actualResult) { errorDesc = "UIntPtr " + srcUIntPtr + " should not equal object" + obj; TestLibrary.TestFramework.LogError("009" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("010" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return(retVal); }
/// <summary> /// This fetches bound outputs after running the model with RunWithBinding() /// </summary> /// <returns>IDisposableReadOnlyCollection<OrtValue></returns> public IDisposableReadOnlyCollection <OrtValue> GetOutputValues() { IntPtr ortValues = IntPtr.Zero; UIntPtr count = UIntPtr.Zero; var allocator = OrtAllocator.DefaultInstance; NativeApiStatus.VerifySuccess(NativeMethods.OrtGetBoundOutputValues(handle, allocator.Pointer, out ortValues, out count)); if (count.Equals(UIntPtr.Zero)) { return(new DisposableList <OrtValue>()); } using (var ortValuesAllocation = new OrtMemoryAllocation(allocator, ortValues, 0)) { int outputCount = (int)count; var ortList = new DisposableList <OrtValue>(outputCount); try { for (int i = 0; i < outputCount; ++i) { IntPtr ortValue = Marshal.ReadIntPtr(ortValues, IntPtr.Size * i); ortList.Add(new OrtValue(ortValue)); } } catch (Exception e) { ortList.Dispose(); throw e; } return(ortList); } }
public virtual bool runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; UIntPtr ip1; UIntPtr ip2; UInt32 iValue; try { strLoc = "Loc_743wg"; iValue = 16; ip1 = new UIntPtr(iValue); ip2 = new UIntPtr(iValue); iCountTestcases++; if(!ip1.Equals(ip2)){ iCountErrors++; Console.WriteLine("Err_865sg! Wrong value returned"); } strLoc = "Loc_9047tdsg"; iValue = 16; ip1 = new UIntPtr(iValue); ip2 = new UIntPtr(iValue*2); iCountTestcases++; if(ip1.Equals(ip2)){ iCountErrors++; Console.WriteLine("Err_9765sgf! Wrong value returned"); } strLoc = "Loc_98736zdg"; iValue = 16; ip1 = new UIntPtr(iValue); iCountTestcases++; if(ip1.Equals(iValue)){ iCountErrors++; Console.WriteLine("Err_9756gf! Wrong value returned"); } strLoc = "Loc_98736zdg"; iValue = 16; ip1 = new UIntPtr(iValue); iCountTestcases++; if(ip1.Equals(null)){ iCountErrors++; Console.WriteLine("Err_973sdg! Wrong value returned"); } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general); } if ( iCountErrors == 0 ) { Console.Error.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.Error.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
internal static T[] OutParamsToArray <T>(OutMethod <T> outMethod) { UIntPtr out_size = outMethod(null, UIntPtr.Zero); if (out_size.Equals(UIntPtr.Zero)) { return(new T[0]); } T[] array = new T[out_size.ToUInt64()]; outMethod(array, out_size); return(array); }
internal static T[] OutParamsToArray <T>(OutMethod <T> outMethod) { UIntPtr ptr = outMethod(null, UIntPtr.Zero); if (ptr.Equals(UIntPtr.Zero)) { return(new T[0]); } T[] localArray = new T[ptr.ToUInt64()]; outMethod(localArray, ptr); return(localArray); }
public static void Equals(UIntPtr ptr1, object obj, bool expected) { if (obj is UIntPtr) { UIntPtr ptr2 = (UIntPtr)obj; Assert.Equal(expected, ptr1 == ptr2); Assert.Equal(!expected, ptr1 != ptr2); Assert.Equal(expected, ptr1.GetHashCode().Equals(ptr2.GetHashCode())); } Assert.Equal(expected, ptr1.Equals(obj)); Assert.Equal(ptr1.GetHashCode(), ptr1.GetHashCode()); }
internal static T[] OutParamsToArray <T>(PInvokeUtilities.OutMethod <T> outMethod) { UIntPtr out_size = outMethod((T[])null, UIntPtr.Zero); if (out_size.Equals((object)UIntPtr.Zero)) { return(new T[0]); } T[] out_bytes = new T[out_size.ToUInt64()]; IntPtr num = (IntPtr)outMethod(out_bytes, out_size); return(out_bytes); }
internal static byte[] OutParamsToBytes(OutBytesMethod outBytesMethod) { UIntPtr requiredSize = outBytesMethod(null, UIntPtr.Zero); if (requiredSize.Equals(UIntPtr.Zero)) { return(new byte[0]); } byte[] bytes = new byte[requiredSize.ToUInt64()]; outBytesMethod(bytes, requiredSize); return(bytes); }
internal static string OutParamsToString(OutStringMethod outStringMethod) { UIntPtr ptr = outStringMethod(null, UIntPtr.Zero); if (ptr.Equals(UIntPtr.Zero)) { return(null); } StringBuilder builder = new StringBuilder((int)ptr.ToUInt32()); outStringMethod(builder, ptr); return(builder.ToString()); }
internal static string OutParamsToString(PInvokeUtilities.OutStringMethod outStringMethod) { UIntPtr out_size = outStringMethod((StringBuilder)null, UIntPtr.Zero); if (out_size.Equals((object)UIntPtr.Zero)) { return((string)null); } StringBuilder out_string = new StringBuilder((int)out_size.ToUInt32()); IntPtr num = (IntPtr)outStringMethod(out_string, out_size); return(out_string.ToString()); }
internal static String OutParamsToString(OutStringMethod outStringMethod) { UIntPtr requiredSize = outStringMethod(null, UIntPtr.Zero); if (requiredSize.Equals(UIntPtr.Zero)) { return(null); } StringBuilder sizedBuilder = new StringBuilder((int)requiredSize.ToUInt32()); outStringMethod(sizedBuilder, requiredSize); return(sizedBuilder.ToString()); }
internal static string OutParamsToString(OutStringMethod outStringMethod) { UIntPtr ptr = outStringMethod(null, UIntPtr.Zero); if (ptr.Equals(UIntPtr.Zero)) { return(null); } try { byte[] buffer = new byte[ptr.ToUInt32()]; outStringMethod(buffer, ptr); return(Encoding.UTF8.GetString(buffer, 0, ((int)ptr.ToUInt32()) - 1)); } catch (Exception exception) { UnityEngine.Debug.LogError("Exception creating string from char array: " + exception); return(string.Empty); } }
/// <summary> /// Returns an array of output names in the same order they were bound /// </summary> /// <returns>array of output names</returns> public string[] GetOutputNames() { IntPtr buffer = IntPtr.Zero; IntPtr lengths = IntPtr.Zero; UIntPtr count = UIntPtr.Zero; var allocator = OrtAllocator.DefaultInstance; NativeApiStatus.VerifySuccess(NativeMethods.OrtGetBoundOutputNames(handle, allocator.Pointer, out buffer, out lengths, out count)); if (count.Equals(UIntPtr.Zero)) { return(new string[0]); } using (var bufferAllocation = new OrtMemoryAllocation(allocator, buffer, 0)) using (var lengthsAllocation = new OrtMemoryAllocation(allocator, lengths, 0)) { int outputCount = (int)count; var lens = new int[outputCount]; int totalLength = 0; for (int i = 0; i < outputCount; ++i) { var len = (int)Marshal.ReadIntPtr(lengths, IntPtr.Size * i); lens[i] = len; totalLength += len; } var stringData = new byte[totalLength]; Marshal.Copy(buffer, stringData, 0, stringData.Length); string[] result = new string[outputCount]; int readOffset = 0; for (int i = 0; i < outputCount; ++i) { var strLen = lens[i]; result[i] = Encoding.UTF8.GetString(stringData, readOffset, strLen); readOffset += strLen; } return(result); } }
internal static string OutParamsToString(OutStringMethod outStringMethod) { UIntPtr out_size = outStringMethod(null, UIntPtr.Zero); if (!out_size.Equals(UIntPtr.Zero)) { string text = null; try { byte[] array = new byte[out_size.ToUInt32()]; outStringMethod(array, out_size); return(Encoding.UTF8.GetString(array, 0, (int)(out_size.ToUInt32() - 1))); } catch (Exception arg) { Debug.LogError((object)("Exception creating string from char array: " + arg)); return(string.Empty); } } return(null); }
public bool PosTest3() { bool retVal = true; const string c_TEST_ID = "P003"; const string c_TEST_DESC = "PosTest3: two UIntPtrs with random value"; string errorDesc; UIntPtr uiPtrA, uiPtrB; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { UInt32 uiA = (UInt32)TestLibrary.Generator.GetInt32(-55); UInt32 uiB = (UInt32)TestLibrary.Generator.GetInt32(-55); uiPtrA = new UIntPtr(uiA); uiPtrB = new UIntPtr(uiB); actualResult = uiPtrA.Equals(uiPtrB); actualResult = !((uiA == uiB) ^ actualResult); if (!actualResult) { errorDesc = "UIntPtr " + uiPtrA + " vs UIntPtr " + uiPtrB + " is " + actualResult + ", that differs from UInt32 " + uiA + " vs UInt32 " + uiB; TestLibrary.TestFramework.LogError("005" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("006" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return(retVal); }
internal static String OutParamsToString(OutStringMethod outStringMethod) { UIntPtr requiredSize = outStringMethod(null, UIntPtr.Zero); if (requiredSize.Equals(UIntPtr.Zero)) { return(null); } string str = null; try { byte[] array = new byte[requiredSize.ToUInt32()]; outStringMethod(array, requiredSize); str = Encoding.UTF8.GetString(array, 0, (int)requiredSize.ToUInt32() - 1); } catch (Exception e) { Debug.LogError("Exception creating string from char array: " + e); str = string.Empty; } return(str); }
public bool PosTest6() { bool retVal = true; const string c_TEST_ID = "P006"; const string c_TEST_DESC = "PosTest6: UIntPtr vs IntPtr"; string errorDesc; UIntPtr uiPtr; IntPtr iPtr; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { void *ptr = (void *)TestLibrary.Generator.GetInt32(-55); uiPtr = new UIntPtr(ptr); iPtr = new IntPtr(ptr); actualResult = !uiPtr.Equals(iPtr); if (!actualResult) { errorDesc = "UIntPtr " + uiPtr + " should not equal IntPtr " + iPtr; TestLibrary.TestFramework.LogError("011" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("012" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return(retVal); }
/// <summary> /// Get ValueNames from registry for WoW64 machine. Corresponding to Microsoft.Win32.RegistryKey.GetValueNames(). /// </summary> /// <param name="registryKey">Registry key string value</param> /// <param name="ulOptions">Access key value options</param> /// <returns></returns> public static string[] GetValueNamesWow64(string registryKey, int ulOptions) { UIntPtr hKey = UIntPtr.Zero; UIntPtr nameKey = UIntPtr.Zero; int lResult = 0; string[] valueNames = null; try { lResult = NativeMethods.RegOpenKeyEx(NativeMethods.HKEY_LOCAL_MACHINE, registryKey, 0, ulOptions, out nameKey); } catch { // Ignore native exceptions. } if (lResult == 0 && UIntPtr.Equals(nameKey, UIntPtr.Zero) == false) { uint numSubKeys, numValues = 0; try { lResult = NativeMethods.RegQueryInfoKey(nameKey, null, IntPtr.Zero, IntPtr.Zero, out numSubKeys, IntPtr.Zero, IntPtr.Zero, out numValues, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); } catch { // Ignore native exceptions. } if (lResult == 0) { valueNames = new string[numValues]; for (uint index = 0; index < numValues; index++) { StringBuilder builder = new StringBuilder(KeyValueNameLength); uint size = KeyValueNameLength; try { lResult = NativeMethods.RegEnumValue(nameKey, index, builder, ref size, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); } catch { // Ignore native exceptions. } if (lResult == 0) { valueNames[index] = builder.ToString(); } } } } if (valueNames != null) { return(valueNames); } else { return(new string[0]); } }
public static void TestEquals(UIntPtr ptr1, object obj, bool expected) { if (obj is UIntPtr) { UIntPtr ptr2 = (UIntPtr)obj; Assert.Equal(expected, ptr1 == ptr2); Assert.Equal(!expected, ptr1 != ptr2); Assert.Equal(expected, ptr1.GetHashCode().Equals(ptr2.GetHashCode())); } Assert.Equal(expected, ptr1.Equals(obj)); Assert.Equal(ptr1.GetHashCode(), ptr1.GetHashCode()); }
public virtual bool runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; UIntPtr ip1; UIntPtr ip2; UInt32 iValue; try { strLoc = "Loc_743wg"; iValue = 16; ip1 = new UIntPtr(iValue); ip2 = new UIntPtr(iValue); iCountTestcases++; if (!ip1.Equals(ip2)) { iCountErrors++; Console.WriteLine("Err_865sg! Wrong value returned"); } strLoc = "Loc_9047tdsg"; iValue = 16; ip1 = new UIntPtr(iValue); ip2 = new UIntPtr(iValue * 2); iCountTestcases++; if (ip1.Equals(ip2)) { iCountErrors++; Console.WriteLine("Err_9765sgf! Wrong value returned"); } strLoc = "Loc_98736zdg"; iValue = 16; ip1 = new UIntPtr(iValue); iCountTestcases++; if (ip1.Equals(iValue)) { iCountErrors++; Console.WriteLine("Err_9756gf! Wrong value returned"); } strLoc = "Loc_98736zdg"; iValue = 16; ip1 = new UIntPtr(iValue); iCountTestcases++; if (ip1.Equals(null)) { iCountErrors++; Console.WriteLine("Err_973sdg! Wrong value returned"); } } catch (Exception exc_general) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev + " Error Err_8888yyy! strLoc==" + strLoc + ", exc_general==" + exc_general); } if (iCountErrors == 0) { Console.Error.WriteLine("paSs. " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases); return(true); } else { Console.Error.WriteLine("FAiL! " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums); return(false); } }
public bool PosTest3() { bool retVal = true; const string c_TEST_ID = "P003"; const string c_TEST_DESC = "PosTest3: two UIntPtrs with random value"; string errorDesc; UIntPtr uiPtrA, uiPtrB; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { UInt32 uiA = (UInt32)TestLibrary.Generator.GetInt32(-55); UInt32 uiB = (UInt32)TestLibrary.Generator.GetInt32(-55); uiPtrA = new UIntPtr(uiA); uiPtrB = new UIntPtr(uiB); actualResult = uiPtrA.Equals(uiPtrB); actualResult = !((uiA == uiB) ^ actualResult); if (!actualResult) { errorDesc = "UIntPtr " + uiPtrA + " vs UIntPtr " + uiPtrB + " is " + actualResult + ", that differs from UInt32 " + uiA + " vs UInt32 " + uiB; TestLibrary.TestFramework.LogError("005" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("006" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return retVal; }
public bool Equals(ID other) => id.Equals(other.id);
public bool PosTest4() { bool retVal = true; const string c_TEST_ID = "P004"; const string c_TEST_DESC = "PosTest4: UIntPtr vs UInt32"; string errorDesc; UIntPtr srcUIntPtr; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { UInt32 ui = (UInt32)TestLibrary.Generator.GetInt32(-55); srcUIntPtr = new UIntPtr(ui); actualResult = !srcUIntPtr.Equals(ui); if (!actualResult) { errorDesc = "UIntPtr " + srcUIntPtr + " should not equal UInt" + ui; TestLibrary.TestFramework.LogError("007" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("008" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return retVal; }
public bool PosTest5() { bool retVal = true; const string c_TEST_ID = "P005"; const string c_TEST_DESC = "PosTest5: UIntPtr vs Object"; string errorDesc; UIntPtr srcUIntPtr; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { object obj = new object(); srcUIntPtr = new UIntPtr(); actualResult = !srcUIntPtr.Equals(obj); if (!actualResult) { errorDesc = "UIntPtr " + srcUIntPtr + " should not equal object" + obj; TestLibrary.TestFramework.LogError("009" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("010" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return retVal; }
public bool PosTest6() { bool retVal = true; const string c_TEST_ID = "P006"; const string c_TEST_DESC = "PosTest6: UIntPtr vs IntPtr"; string errorDesc; UIntPtr uiPtr; IntPtr iPtr; bool actualResult; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { void * ptr = (void *)TestLibrary.Generator.GetInt32(-55); uiPtr = new UIntPtr(ptr); iPtr = new IntPtr(ptr); actualResult = !uiPtr.Equals(iPtr); if (!actualResult) { errorDesc = "UIntPtr " + uiPtr + " should not equal IntPtr " + iPtr; TestLibrary.TestFramework.LogError("011" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("012" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return retVal; }
public static unsafe void TestBasics() { UIntPtr p; uint i; ulong l; if (sizeof(void *) == 4) { // Skip UIntPtr tests on 32-bit platforms return; } int size = UIntPtr.Size; Assert.Equal(size, sizeof(void *)); TestPointer(UIntPtr.Zero, 0); i = 42; TestPointer(new UIntPtr(i), i); TestPointer((UIntPtr)i, i); i = 42; TestPointer(new UIntPtr(i), i); l = 0x0fffffffffffffff; TestPointer(new UIntPtr(l), l); TestPointer((UIntPtr)l, l); void *pv = new UIntPtr(42).ToPointer(); TestPointer(new UIntPtr(pv), 42); TestPointer((UIntPtr)pv, 42); p = UIntPtr.Add(new UIntPtr(42), 5); TestPointer(p, 42 + 5); // Add is spected NOT to generate an OverflowException p = UIntPtr.Add(new UIntPtr(0xffffffffffffffff), 5); unchecked { TestPointer(p, (long)0x0000000000000004); } p = UIntPtr.Subtract(new UIntPtr(42), 5); TestPointer(p, 42 - 5); bool b; p = new UIntPtr(42); b = p.Equals(null); Assert.False(b); b = p.Equals((object)42); Assert.False(b); b = p.Equals((object)(new UIntPtr(42))); Assert.True(b); int h = p.GetHashCode(); int h2 = p.GetHashCode(); Assert.Equal(h, h2); p = new UIntPtr(42); i = (uint)p; Assert.Equal(i, 42u); l = (ulong)p; Assert.Equal(l, 42u); UIntPtr p2; p2 = (UIntPtr)i; Assert.Equal(p, p2); p2 = (UIntPtr)l; Assert.Equal(p, p2); p2 = (UIntPtr)(p.ToPointer()); Assert.Equal(p, p2); p2 = new UIntPtr(40) + 2; Assert.Equal(p, p2); p2 = new UIntPtr(44) - 2; Assert.Equal(p, p2); p = new UIntPtr(0x7fffffffffffffff); Assert.Throws <OverflowException>(() => (uint)p); }
public bool Equals(Win32RegistrySubkeyIter other) { return(true && _key.Equals(other._key) && counter.Equals(other.counter) && subkey_count.Equals(other.subkey_count) && _subkey_name.Equals(other._subkey_name) && subkey_name_size.Equals(other.subkey_name_size) && subkey_name_len.Equals(other.subkey_name_len) && subkey_name_u8.Equals(other.subkey_name_u8)); }
public static unsafe void TestBasics() { UIntPtr p; uint i; ulong l; if (sizeof(void*) == 4) { // Skip UIntPtr tests on 32-bit platforms return; } int size = UIntPtr.Size; Assert.Equal(size, sizeof(void*)); TestPointer(UIntPtr.Zero, 0); i = 42; TestPointer(new UIntPtr(i), i); TestPointer((UIntPtr)i, i); i = 42; TestPointer(new UIntPtr(i), i); l = 0x0fffffffffffffff; TestPointer(new UIntPtr(l), l); TestPointer((UIntPtr)l, l); void* pv = new UIntPtr(42).ToPointer(); TestPointer(new UIntPtr(pv), 42); TestPointer((UIntPtr)pv, 42); p = UIntPtr.Add(new UIntPtr(42), 5); TestPointer(p, 42 + 5); // Add is spected NOT to generate an OverflowException p = UIntPtr.Add(new UIntPtr(0xffffffffffffffff), 5); unchecked { TestPointer(p, (long)0x0000000000000004); } p = UIntPtr.Subtract(new UIntPtr(42), 5); TestPointer(p, 42 - 5); bool b; p = new UIntPtr(42); b = p.Equals(null); Assert.False(b); b = p.Equals((object)42); Assert.False(b); b = p.Equals((object)(new UIntPtr(42))); Assert.True(b); int h = p.GetHashCode(); int h2 = p.GetHashCode(); Assert.Equal(h, h2); p = new UIntPtr(42); i = (uint)p; Assert.Equal(i, 42u); l = (ulong)p; Assert.Equal(l, 42u); UIntPtr p2; p2 = (UIntPtr)i; Assert.Equal(p, p2); p2 = (UIntPtr)l; Assert.Equal(p, p2); p2 = (UIntPtr)(p.ToPointer()); Assert.Equal(p, p2); p2 = new UIntPtr(40) + 2; Assert.Equal(p, p2); p2 = new UIntPtr(44) - 2; Assert.Equal(p, p2); p = new UIntPtr(0x7fffffffffffffff); Assert.Throws<OverflowException>(() => (uint)p); }
public bool Equals(Win32RegistryValueIter other) { return(true && _key.Equals(other._key) && counter.Equals(other.counter) && value_count.Equals(other.value_count) && _value_name.Equals(other._value_name) && value_name_size.Equals(other.value_name_size) && value_name_len.Equals(other.value_name_len) && value_type.Equals(other.value_type) && _value_data.Equals(other._value_data) && value_data_size.Equals(other.value_data_size) && value_actual_data_size.Equals(other.value_actual_data_size) && value_expanded_type.Equals(other.value_expanded_type) && _value_data_expanded.Equals(other._value_data_expanded) && value_data_expanded_charsize.Equals(other.value_data_expanded_charsize) && value_name_u8.Equals(other.value_name_u8) && value_name_u8_len.Equals(other.value_name_u8_len) && value_data_u8.Equals(other.value_data_u8) && value_data_u8_size.Equals(other.value_data_u8_size) && value_data_expanded_u8.Equals(other.value_data_expanded_u8) && value_data_expanded_u8_size.Equals(other.value_data_expanded_u8_size)); }