public override int GetHashCode() { unchecked { var hashCode = (StringVal != null ? StringVal.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IntVal; hashCode = (hashCode * 397) ^ BooleanVal.GetHashCode(); hashCode = (hashCode * 397) ^ ByteVal.GetHashCode(); hashCode = (hashCode * 397) ^ LongVal.GetHashCode(); hashCode = (hashCode * 397) ^ FloatVal.GetHashCode(); hashCode = (hashCode * 397) ^ DoubleVal.GetHashCode(); hashCode = (hashCode * 397) ^ DateTimeVal.GetHashCode(); hashCode = (hashCode * 397) ^ ShortVal.GetHashCode(); hashCode = (hashCode * 397) ^ UShortVal.GetHashCode(); hashCode = (hashCode * 397) ^ (int)UIntVal; hashCode = (hashCode * 397) ^ ULongVal.GetHashCode(); hashCode = (hashCode * 397) ^ SByteVal.GetHashCode(); hashCode = (hashCode * 397) ^ CharVal.GetHashCode(); return(hashCode); } }
public Boolean runTest() { int iCountTestcases = 0; int iCountErrors = 0; Console.Error.WriteLine(strName + ": " + strTest + " runTest started..."); String strValue = null; SByte SByteVal; SByte sb = (SByte)4; sb = (SByte)(sb + (SByte)2); for (SByteVal = (SByte)SByte.MinValue; ; SByteVal = (SByte)(SByteVal + (SByte)(1))) { iCountTestcases++; strValue = Convert.ToString((long)SByteVal, 10); SByte SByteRet = 0x1; try { SByteRet = SByte.Parse(strValue); if (SByteVal != SByteRet) { String strInfo = "Parse error: "; strInfo = strInfo + "Expected Result = <"; strInfo = strInfo + SByteVal.ToString(); strInfo = strInfo + "> "; strInfo = strInfo + "Returned Result = <"; strInfo = strInfo + SByteRet.ToString(); strInfo = strInfo + "> "; Console.WriteLine(strTest + "E_101"); Console.WriteLine(strTest + strInfo); ++iCountErrors; break; } else if (SByteVal == SByte.MaxValue) { break; } } catch (Exception exc) { ++iCountErrors; print("E_uey7"); printexc(exc); break; } } try { iCountTestcases++; strValue = "1000"; SByteVal = SByte.Parse(strValue); ++iCountErrors; print("E_o88"); } catch (OverflowException) { } catch (Exception exc) { ++iCountErrors; print("E_i28"); printexc(exc); } try { iCountTestcases++; strValue = "-1000"; SByteVal = SByte.Parse(strValue); ++iCountErrors; print("E_hj28"); } catch (OverflowException) { } catch (Exception exc) { ++iCountErrors; print("E_hjk3"); printexc(exc); } try { iCountTestcases++; strValue = "This is an invalid string"; SByteVal = SByte.Parse(strValue); ++iCountErrors; print("E_h282"); } catch (FormatException) { } catch (Exception exc) { ++iCountErrors; print("E_h287"); printexc(exc); } try { iCountTestcases++; strValue = null; SByteVal = SByte.Parse(strValue); ++iCountErrors; print("E_k39"); } catch (ArgumentException) { } catch (Exception exc) { ++iCountErrors; print("E_1414"); printexc(exc); } if (iCountErrors == 0) { Console.Error.WriteLine("paSs. " + strTest + " iCountTestCases == " + iCountTestcases); return(true); } else { Console.Error.WriteLine("FAiL. " + strTest + " iCountErrors==" + iCountErrors); return(false); } }