static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.Divide); if (Sse2.IsSupported) { using (var doubleTable = TestTableSse2 <double> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>, Vector128 <double>)value = doubleTable[i]; var result = Sse2.Divide(value.Item1, value.Item2); doubleTable.SetOutArray(result); } CheckMethod <double> checkDouble = (double x, double y, double z, ref double a) => (a = x / y) == z; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x / y) == z", checkDouble); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
private void CheckAssertionFor(CheckMethod checkMethod) { if (IsCheckMethodSelected(checkMethod)) { Assertions.CheckAssertions(this); } }
public WhereSpecifier(string column, CheckMethod method, string value, CheckMethodModifiers modifiers) { Modifiers = modifiers; Value = value; Column = column; Method = method; }
public static T Create <T> (CheckMethod checkOnMethods, GameObject gameObject, string propertyPath, object constValue) where T : ComparerBase { AssertionComponentConfigurator configurator; return(Create <T> (out configurator, checkOnMethods, gameObject, propertyPath, constValue)); }
private bool KeyCheckMethod(int actionCode, CheckMethod method) { int i = FindActionCode(actionCode); if (i >= 0) { KeyCode kcode = mapList[i].bind1; if (kcode != KeyCode.None) { if (Input.GetKeyDown(kcode)) { return(true); } } kcode = mapList[i].bind2; if (kcode != KeyCode.None) { if (Input.GetKeyDown(kcode)) { return(true); } } } return(false); }
public CheckParameter(CheckMethod method, CheckOperator op, object failedvalue, object warningvalue, string description) { this.Method = method; this.Operator = op; this.FailedValue = failedvalue; this.WarningValue = warningvalue; this.Description = description; }
public bool SetChecker(CheckMethod checker) { if (this.Checker != null) { return(false); } this.Checker = checker; return(true); }
public KeyMap(KeyCode[] k, string name, Action act, CheckMethod check, float time) { this.key = k; this.name = name; this.action = act; this.dTime = time; this.check = check; lastTime = Time.fixedTime; }
public static T Create <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath, GameObject gameObject2, string propertyPath2) where T : ComparerBase { var comparer = CreateAssertionComponent <T>(out configurator, checkOnMethods, gameObject, propertyPath); comparer.compareToType = ComparerBase.CompareToType.CompareToObject; comparer.other = gameObject2; comparer.otherPropertyPath = propertyPath2; return(comparer); }
internal static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.Multiply); if (Sse2.IsSupported) { using (var doubleTable = TestTableSse2 <double> .Create(testsCount)) using (var uintTable = TestTableSse2 <uint, ulong> .Create(testsCount, 2.0)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>, Vector128 <double>)value = doubleTable[i]; Vector128 <double> result = Sse2.Multiply(value.Item1, value.Item2); doubleTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <uint>, Vector128 <uint>)value = uintTable[i]; Vector128 <ulong> result = Sse2.Multiply(value.Item1, value.Item2); uintTable.SetOutArrayU(result); } CheckMethod <double> checkDouble = (double x, double y, double z, ref double a) => (a = x * y) == z; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x * y) == z", checkDouble); testResult = Fail; } CheckMethodFive <uint, ulong> checkUInt32 = (uint x1, uint x2, uint y1, uint y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) => { a1 = (ulong)x1 * y1; a2 = (ulong)x2 * y2; return(a1 == z1 && a2 == z2); }; if (!uintTable.CheckMultiplyUInt32ToUInt64(checkUInt32)) { PrintError(uintTable, methodUnderTestName, "(uint x1, uint x2, uint y1, uint y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) => (a1 = (ulong)x1 * y1) == z1 && (a2 = (ulong)x2 * y2) == z2", checkUInt32); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
public static T Create <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath, object constValue) where T : ComparerBase { var comparer = CreateAssertionComponent <T>(out configurator, checkOnMethods, gameObject, propertyPath); if (constValue == null) { comparer.compareToType = ComparerBase.CompareToType.CompareToNull; return(comparer); } comparer.compareToType = ComparerBase.CompareToType.CompareToConstantValue; comparer.ConstValue = constValue; return(comparer); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.Average); if (Sse2.IsSupported) { using (var ushortTable = TestTableSse2 <ushort> .Create(testsCount)) using (var byteTable = TestTableSse2 <byte> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <ushort>, Vector128 <ushort>, Vector128 <ushort>)value = ushortTable[i]; Vector128 <ushort> result = Sse2.Average(value.Item1, value.Item2); ushortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <byte>, Vector128 <byte>, Vector128 <byte>)value = byteTable[i]; Vector128 <byte> result = Sse2.Average(value.Item1, value.Item2); byteTable.SetOutArray(result); } CheckMethod <ushort> checkUshort = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)((x + y + 1) >> 1)) == z; if (!ushortTable.CheckResult(checkUshort)) { PrintError(ushortTable, methodUnderTestName, "(x, y, z, ref a) => (a = (x + y + 1) >> 1) == z", checkUshort); testResult = Fail; } CheckMethod <byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)((x + y + 1) >> 1)) == z; if (!byteTable.CheckResult(checkByte)) { PrintError(byteTable, methodUnderTestName, "(x, y, z, ref a) => (a = (x + y + 1) >> 1) == z", checkByte); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
internal static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.MultiplyHigh); if (Sse2.IsSupported) { using (var shortTable = TestTableSse2 <short> .Create(testsCount)) using (var ushortTable = TestTableSse2 <ushort> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <short>, Vector128 <short>, Vector128 <short>)value = shortTable[i]; Vector128 <short> result = Sse2.MultiplyHigh(value.Item1, value.Item2); shortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <ushort>, Vector128 <ushort>, Vector128 <ushort>)value = ushortTable[i]; Vector128 <ushort> result = Sse2.MultiplyHigh(value.Item1, value.Item2); ushortTable.SetOutArray(result); } CheckMethod <short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)((x * y) >> 16)) == z; if (!shortTable.CheckResult(checkInt16)) { PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)((x * y) >> 16)) == z", checkInt16); testResult = Fail; } CheckMethod <ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)((x * y) >> 16)) == z; if (!ushortTable.CheckResult(checkUInt16)) { PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)((x * y) >> 16)) == z", checkUInt16); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.CompareUnordered); if (Sse2.IsSupported) { using (var doubleTable = TestTableSse2 <double> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>, Vector128 <double>)value = doubleTable[i]; var result = Sse2.CompareUnordered(value.Item1, value.Item2); doubleTable.SetOutArray(result); } CheckMethod <double> checkDouble = (double x, double y, double z, ref double a) => { if (double.IsNaN(x) || double.IsNaN(y)) { a = BitConverter.Int64BitsToDouble(-1); } else { a = 0; } return(BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z)); }; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = (double.IsNaN(x) || double.IsNaN(y)) ? double.NaN : 0) == z", checkDouble); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
public override bool OnRebuildObservers(HashSet <NetworkConnection> observers, bool initial) { if (this.forceHidden) { NetworkIdentity component = base.GetComponent <NetworkIdentity>(); if (component.connectionToClient != null) { observers.Add(component.connectionToClient); } return(true); } CheckMethod checkMethod = this.checkMethod; if (checkMethod != CheckMethod.Physics3D) { if (checkMethod != CheckMethod.Physics2D) { return(false); } } else { foreach (Collider collider in Physics.OverlapSphere(base.transform.position, (float)this.visRange)) { NetworkIdentity identity2 = collider.GetComponent <NetworkIdentity>(); if ((identity2 != null) && (identity2.connectionToClient != null)) { observers.Add(identity2.connectionToClient); } } return(true); } foreach (Collider2D colliderd in Physics2D.OverlapCircleAll(base.transform.position, (float)this.visRange)) { NetworkIdentity identity3 = colliderd.GetComponent <NetworkIdentity>(); if ((identity3 != null) && (identity3.connectionToClient != null)) { observers.Add(identity3.connectionToClient); } } return(true); }
//Method public override double?GetProperty(int index) { try { DataRow rowtemp = this._Data.GetDataRow(index); if (rowtemp[ChooseColumnName].ToString() == false.ToString()) { return(null); } var temp = rowtemp[Param]; if (!CheckMethod.checkDoubleCanConvert(temp)) { return(0); } return(Convert.ToDouble(temp)); } catch { return(0); } }
internal static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.MultiplyLow); if (Sse2.IsSupported) { using (var shortTable = TestTableSse2 <short> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <short>, Vector128 <short>, Vector128 <short>)value = shortTable[i]; Vector128 <short> result = Sse2.MultiplyLow(value.Item1, value.Item2); shortTable.SetOutArray(result); } CheckMethod <short> checkInt16 = (short x, short y, short z, ref short a) => { var tmp = ((int)x * y) * 0x0000ffff; a = unchecked ((short)tmp); return(-a == z); }; if (!shortTable.CheckResult(checkInt16)) { PrintError(shortTable, methodUnderTestName, "(short x, short y, int z, ref int a) => (a = (int)x * y >> 16 | sign) == z", checkInt16); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
public bool IsCheckMethodSelected (CheckMethod method) { return method == (checkMethods & method); }
private void CheckAssertionFor (CheckMethod checkMethod) { if (IsCheckMethodSelected (checkMethod)) { Assertions.CheckAssertions (this); } }
private bool FindPath(int click, int matchTarget, CheckMethod method) { bool f = false; int mindis = 999999; int lastNodeIndex = -1; if (GetIconArray(click) != GetIconArray(matchTarget)) { return(false); } List <LinkUnit> list = new List <LinkUnit>(); list.Add(new LinkUnit(click, 0, 0, -1)); int totalColumn = ColumnCount + 2; for (int i = 0; i < 3 && !f; i++) { for (int j = 0; j < list.Count; j++) { if (list[j].Depth == i) { for (int k = list[j].Value - 1, dis = 0; k >= list[j].Value - (list[j].Value % totalColumn); k--, dis++) { if (TryCell(matchTarget, k, list, j, dis, ref mindis, ref lastNodeIndex, ref f)) { break; } } for (int k = list[j].Value + 1, dis = 0; k <= list[j].Value - (list[j].Value % totalColumn) + totalColumn - 1; k++, dis++) { if (TryCell(matchTarget, k, list, j, dis, ref mindis, ref lastNodeIndex, ref f)) { break; } } for (int k = list[j].Value - totalColumn, dis = 0; k >= 0; k -= totalColumn, dis++) { if (TryCell(matchTarget, k, list, j, dis, ref mindis, ref lastNodeIndex, ref f)) { break; } } for (int k = list[j].Value + totalColumn, dis = 0; k < totalColumn * (RowCount + 2); k += totalColumn, dis++) { if (TryCell(matchTarget, k, list, j, dis, ref mindis, ref lastNodeIndex, ref f)) { break; } } } } } if (!f) { return(false); } if (method == CheckMethod.Try) { DrawMatchLine(click, matchTarget, lastNodeIndex, list); } return(true); }
private static T CreateAssertionComponent <T> (out AssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath) where T : ActionBase { var ac = gameObject.AddComponent <AssertionComponent> (); ac.checkMethods = checkOnMethods; var comparer = ScriptableObject.CreateInstance <T> (); ac.Action = comparer; ac.Action.go = gameObject; ac.Action.thisPropertyPath = propertyPath; configurator = ac; var stackTrace = new System.Diagnostics.StackTrace(true); var thisFileName = stackTrace.GetFrame(0).GetFileName(); for (int i = 1; i < stackTrace.FrameCount; i++) { var stackFrame = stackTrace.GetFrame(i); if (stackFrame.GetFileName() != thisFileName) { string filePath = stackFrame.GetFileName().Substring(Application.dataPath.Length - "Assets".Length); ac.createdInFilePath = filePath; ac.createdInFileLine = stackFrame.GetFileLineNumber(); break; } } return(comparer); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.Min); if (Sse2.IsSupported) { using (var doubleTable = TestTableSse2 <double> .Create(testsCount)) using (var shortTable = TestTableSse2 <short> .Create(testsCount)) using (var byteTable = TestTableSse2 <byte> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>, Vector128 <double>)value = doubleTable[i]; var result = Sse2.Min(value.Item1, value.Item2); doubleTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <short>, Vector128 <short>, Vector128 <short>)value = shortTable[i]; var result = Sse2.Min(value.Item1, value.Item2); shortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <byte>, Vector128 <byte>, Vector128 <byte>)value = byteTable[i]; var result = Sse2.Min(value.Item1, value.Item2); byteTable.SetOutArray(result); } CheckMethod <double> checkDouble = (double x, double y, double z, ref double a) => (a = x > y ? y : x) == z; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BitwiseOr(x, y)) == z", checkDouble); testResult = Fail; } CheckMethod <short> checkInt16 = (short x, short y, short z, ref short a) => (a = x > y ? y : x) == z; if (!shortTable.CheckResult(checkInt16)) { PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x | y)) == z", checkInt16); testResult = Fail; } CheckMethod <byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = x > y ? y : x) == z; if (!byteTable.CheckResult(checkByte)) { PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x | y)) == z", checkByte); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
public static T Create <T> (out AssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath) where T : ActionBase { return(CreateAssertionComponent <T> (out configurator, checkOnMethods, gameObject, propertyPath)); }
public bool IsCheckMethodSelected(CheckMethod method) { return(method == (checkMethods & method)); }
public WhereSpecifier(string column, CheckMethod method, string value) : this(column, method, value, CheckMethodModifiers.None) { }
/// <summary> /// 校验登记 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChkSAP_Click(object sender, EventArgs e) { try { CommonalityEntity.IsUpdatedri = false; CheckProperties.ce.SapSangFeiTable = null; CheckProperties.ce.SapSongHuoTable = null; CheckProperties.ce.SapChengPinTable = null; CheckProperties.ce.SapSangFeiTable2 = null; CheckProperties.ce.SapSongHuoTable2 = null; CheckProperties.ce.SapChengPinTable2 = null; if (comboxCarType.Text.Trim() == "") { MessageBox.Show("车辆类型不能为空!"); return; } if (txtNumber.Text.Trim() == "") { MessageBox.Show(lblNumber.Text.ToString()); return; } CheckMethod.listMessage.Clear(); //给需要执行的管控赋值 EMEWE.CarManagement.Commons.CommonClass.CheckProperties.CommonEntity comm = new EMEWE.CarManagement.Commons.CommonClass.CheckProperties.CommonEntity(); if (comboxCarType.Text == "送货车辆") { comm.SongHuoNumber = txtNumber.Text.Trim(); } else if (comboxCarType.Text == "成品车辆") { comm.ChengPinNumber = txtNumber.Text.Trim(); } else if (comboxCarType.Text == "三废车辆") { comm.SangFeiNumber = txtNumber.Text.Trim(); } comm.CarType_Name = comboxCarType.Text.Trim(); CheckProperties.ce = comm; //执行管控 if (comboxCarType.Text == "送货车辆") { CheckMethod.ChkSongHuo(); CheckMethod.ChkSongHuoFour(); } else if (comboxCarType.Text == "成品车辆") { CheckMethod.ChkChengPin(); } else if (comboxCarType.Text == "三废车辆") { CheckMethod.ChkSanFei(); } //执行结果 if (CheckMethod.listMessage.Count > 0) { string strmessage = ""; foreach (var item in CheckMethod.listMessage) { strmessage += item; } MessageBox.Show(this, strmessage);; return; } bool istru = false; if (CheckProperties.ce.SapSangFeiTable != null) { lvwUserList.DataSource = CheckProperties.ce.SapSangFeiTable; if (CheckProperties.ce.SapSangFeiTable2.Rows[0][0].ToString() == "S" && CheckProperties.ce.SapSangFeiTable.Rows.Count == 1) { istru = CommonalityEntity.AddSAPVBELNInfo(this.lvwUserList.SelectedRows[0].Cells["VBELN"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["NAME1_C"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["MAKTX"].Value.ToString(), 0, CheckProperties.ce.SapSangFeiTable2); } } if (CheckProperties.ce.SapSongHuoTable != null) { lvwUserList.DataSource = CheckProperties.ce.SapSongHuoTable; if (CheckProperties.ce.SapSongHuoTable2.Rows[0][0].ToString() == "S" && CheckProperties.ce.SapSongHuoTable.Rows.Count == 1) { istru = CommonalityEntity.AddPOInfo(this.lvwUserList.SelectedRows[0].Cells["EBELN"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["NAME1_P"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["MAKTX"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["KDATB"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["KDATE"].Value.ToString(), 0, CheckProperties.ce.SapSongHuoTable2); } } if (CheckProperties.ce.SapChengPinTable != null) { lvwUserList.DataSource = CheckProperties.ce.SapChengPinTable; if (CheckProperties.ce.SapChengPinTable2.Rows[0][0].ToString() == "S" && CheckProperties.ce.SapChengPinTable.Rows.Count == 1) { string carName = this.lvwUserList.SelectedRows[0].Cells["CARNO"].Value.ToString(); string wtdid = this.lvwUserList.SelectedRows[0].Cells["WTD_ID"].Value.ToString(); if (IsSapNo(carName, wtdid)) { MessageBox.Show(this, "该车辆的订单号业务已完成,不能重复登记!"); return; } if (this.lvwUserList.SelectedRows[0].Cells["O_FLAG"].Value.ToString() != "X") { MessageBox.Show("没有装货通知单,不能登记!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); return; } istru = CommonalityEntity.AddWTDIDInfo(this.lvwUserList.SelectedRows[0].Cells["CARNO"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["WTD_ID"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["O_FLAG"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["TEL_NUMBER"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["HG"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["XZ"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["KDATB"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["KDATE"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["NAME1_C"].Value.ToString(), this.lvwUserList.SelectedRows[0].Cells["NAME1_P"].Value.ToString(), 0, this.lvwUserList.SelectedRows[0].Cells["Prodh"].Value.ToString(), CheckProperties.ce.SapChengPinTable2); } } if (istru) { istru = false; CommonalityEntity.ISsap = true; CarInfoForm cif = new CarInfoForm(); cif.Show(); this.Close(); } } catch { CommonalityEntity.WriteTextLog("SAPCarInfoForm btnChkSAP_Click()"); } }
/// <summary> /// 执行管理策略方法 /// 查询语句一般string strSQL = "select * from ManagementStrategy where ManagementStrategy_CarType_ID= ManagementStrategy_DrivewayStrategy_ID=ManagementStrategy_Type=" /// 查询条件:车辆类型编号,通行策略编号,管控策略类型(登记、排队、进厂、出厂) /// </summary> ///<param name="strSql">查询SQl语句</param> public void ExecutionMethod(string strSql) { string s = ""; try { Assembly assem = Assembly.GetExecutingAssembly(); //// Create an object from the assembly, passing in the correct number //// and type of arguments for the constructor. Object o = assem.CreateInstance(NamespaceAndClass); #region 每次执行方法前需置空这些变量 CheckMethod.listSql.Clear(); CheckMethod.listMessage.Clear(); #endregion List <string> listStr = GetMethodsReflect(); #region 循环遍历执行的方法 数据库去获取管控策略 string strMethodName = "";//方法名称 DataSet ds = LinQBaseDao.Query(strSql); if (ds != null) { if (ds.Tables.Count > 0) { if (CommonalityEntity.IsUpdatedri) { foreach (DataRow dr in ds.Tables[0].Rows) { strMethodName = dr["ManagementStrategyRecord_Rule"].ToString(); if (!string.IsNullOrEmpty(strMethodName)) { if (strMethodName == "ISSAPLoadData") { if (CheckProperties.ce.CarType_Name.IndexOf("成品") >= 0) { CheckMethod.ISSAPLoadData(CheckProperties.ce.carInfo_Name, "20"); } else if (CheckProperties.ce.CarType_Name.IndexOf("废纸") >= 0) { CheckMethod.ISSAPLoadData(CheckProperties.ce.carInfo_Name, "10"); } else { CheckMethod.ISSAPLoadData(CheckProperties.ce.carInfo_Name, "30"); } break; } } } foreach (DataRow dr in ds.Tables[0].Rows) { strMethodName = dr["ManagementStrategyRecord_Rule"].ToString(); if (!string.IsNullOrEmpty(strMethodName)) { if (strMethodName == "ISSAPLoadData") { continue; } try { //验证执行的方法是否存在,存在执行方法,不存在做记事本日志记录 if (ISMethod(strMethodName, listStr)) { //如果存在默认值将默认值赋给CheckMethod.DefaultObj if (!string.IsNullOrEmpty(dr["ManagementStrategyRecord_Value"].ToString())) { CheckMethod.DefaultObj = dr["ManagementStrategyRecord_Value"]; } // CommonalityEntity.intCarInOutInfoRecord_ID =CommonalityEntity.GetInt(dr["ManagementStrategy_ID"].ToString()); // 执行指定命名空间类的指定方法 s = strMethodName; MethodInfo m = assem.GetType(NamespaceAndClass).GetMethod(strMethodName); Object ret = m.Invoke(o, new Object[] { }); //如果有参数将参数按方法的顺序存入new Object[] { }里面使用逗号隔开如“new Object[] { 1,2}” if (ret != null) { //判断执行方法的返回值是否为空,不为空将结果放到指定的变量存储 } } else { CommonClass.CommonalityEntity.WriteTextLog("执行管理策略方法未找到" + strMethodName + "方法?"); } } catch (Exception) { } } } } else { foreach (DataRow dr in ds.Tables[0].Rows) { strMethodName = dr["ManagementStrategy_Rule"].ToString(); if (!string.IsNullOrEmpty(strMethodName)) { if (strMethodName == "ISSAPLoadData") { if (CheckProperties.ce.CarType_Name.IndexOf("成品") >= 0) { CheckMethod.ISSAPLoadData(CheckProperties.ce.carInfo_Name, "20"); } else if (CheckProperties.ce.CarType_Name.IndexOf("废纸") >= 0) { CheckMethod.ISSAPLoadData(CheckProperties.ce.carInfo_Name, "10"); } else { CheckMethod.ISSAPLoadData(CheckProperties.ce.carInfo_Name, "30"); } break; } } } foreach (DataRow dr in ds.Tables[0].Rows) { strMethodName = dr["ManagementStrategy_Rule"].ToString(); if (!string.IsNullOrEmpty(strMethodName)) { if (strMethodName == "ISSAPLoadData") { continue; } try { //验证执行的方法是否存在,存在执行方法,不存在做记事本日志记录 if (ISMethod(strMethodName, listStr)) { //如果存在默认值将默认值赋给CheckMethod.DefaultObj if (!string.IsNullOrEmpty(dr["ManagementStrategy_Value"].ToString())) { CheckMethod.DefaultObj = dr["ManagementStrategy_Value"]; } // CommonalityEntity.intCarInOutInfoRecord_ID =CommonalityEntity.GetInt(dr["ManagementStrategy_ID"].ToString()); // 执行指定命名空间类的指定方法 s = strMethodName; MethodInfo m = assem.GetType(NamespaceAndClass).GetMethod(strMethodName); Object ret = m.Invoke(o, new Object[] { }); //如果有参数将参数按方法的顺序存入new Object[] { }里面使用逗号隔开如“new Object[] { 1,2}” if (ret != null) { //判断执行方法的返回值是否为空,不为空将结果放到指定的变量存储 } } else { CommonClass.CommonalityEntity.WriteTextLog("执行管理策略方法未找到" + strMethodName + "方法?"); } } catch (Exception) { } } } } } } #endregion } catch { string a = s; } }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.CompareGreaterThan); if (Sse2.IsSupported) { using (var doubleTable = TestTableSse2 <double> .Create(testsCount)) using (var intTable = TestTableSse2 <int> .Create(testsCount)) using (var shortTable = TestTableSse2 <short> .Create(testsCount)) using (var sbyteTable = TestTableSse2 <sbyte> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>, Vector128 <double>)value = doubleTable[i]; var result = Sse2.CompareGreaterThan(value.Item1, value.Item2); doubleTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <int>, Vector128 <int>, Vector128 <int>)value = intTable[i]; var result = Sse2.CompareGreaterThan(value.Item1, value.Item2); intTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <short>, Vector128 <short>, Vector128 <short>)value = shortTable[i]; var result = Sse2.CompareGreaterThan(value.Item1, value.Item2); shortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <sbyte>, Vector128 <sbyte>, Vector128 <sbyte>)value = sbyteTable[i]; var result = Sse2.CompareGreaterThan(value.Item1, value.Item2); sbyteTable.SetOutArray(result); } CheckMethod <double> checkDouble = (double x, double y, double z, ref double a) => { a = x > y?BitConverter.Int64BitsToDouble(-1) : 0; return(BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z)); }; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = x > y ? double.NaN : 0) == z", checkDouble); testResult = Fail; } CheckMethod <int> checkInt32 = (int x, int y, int z, ref int a) => (a = x > y ? -1 : 0) == z; if (!intTable.CheckResult(checkInt32)) { PrintError(intTable, methodUnderTestName, "(x, y, z, a) => (a = x > y ? -1 : 0) == z", checkInt32); testResult = Fail; } CheckMethod <short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x > y ? -1 : 0)) == z; if (!shortTable.CheckResult(checkInt16)) { PrintError(shortTable, methodUnderTestName, "(x, y, z) => (x > y ? -1 : 0) == z", checkInt16); testResult = Fail; } CheckMethod <sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x > y ? -1 : 0)) == z; if (!sbyteTable.CheckResult(checkSByte)) { PrintError(sbyteTable, methodUnderTestName, "(x, y, z) => (x > y ? -1 : 0) == z", checkSByte); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
/// <summary> /// Validates the rule. /// </summary> /// <param name="context">The validation context.</param> public override void Validate(TrafficValidationContext context) { base.Validate(context); Frontends = Frontends ?? new List <TrafficHttpFrontend>(); Backends = Backends ?? new List <TrafficHttpBackend>(); if (Frontends.Count == 0) { context.Error($"Rule [{Name}] has does not define a frontend."); } if (!string.IsNullOrEmpty(CheckUri)) { if (!Uri.TryCreate(CheckUri, UriKind.Relative, out var uri)) { context.Error($"Rule [{Name}] has invalid [{nameof(CheckUri)}={CheckUri}]."); } } if (string.IsNullOrEmpty(CheckMethod) || CheckMethod.IndexOfAny(new char[] { ' ', '\r', '\n', '\t' }) != -1) { context.Error($"Rule [{Name}] has invalid [{nameof(CheckMethod)}={CheckMethod}]."); } if (string.IsNullOrEmpty(CheckVersion)) { CheckVersion = "1.0"; } var regex = new Regex(@"^\d+\.\d+$"); if (!regex.Match(CheckVersion).Success) { context.Error($"Rule [{Name}] has invalid [{nameof(CheckVersion)}={CheckVersion}]."); } if (!string.IsNullOrEmpty(CheckHost) && !HiveDefinition.DnsHostRegex.Match(CheckHost).Success) { context.Error($"Rule [{Name}] has invalid [{nameof(CheckHost)}={CheckHost}]."); } if (!string.IsNullOrEmpty(CheckExpect)) { var error = $"Rule [{Name}] has invalid [{nameof(CheckExpect)}={CheckExpect}]."; var value = CheckExpect.Trim(); if (value.StartsWith("! ")) { value = value.Substring(2).Trim(); } var pos = value.IndexOf(' '); if (pos == -1) { context.Error(error + " Expected: <match> <pattern>"); } else { var match = value.Substring(0, pos); var pattern = value.Substring(pos).Trim(); if (pattern.Replace("\\ ", string.Empty).IndexOf(' ') != -1) { context.Error(error + $" Pattern [{pattern}] includes unescaped spaces."); } switch (match) { case "status": case "string": break; case "rstatus": case "rstring": try { new Regex(pattern); } catch (Exception e) { context.Error(error + $" Pattern regex [{pattern}] parsing error: {e.Message}."); } break; default: context.Error(error + " Invalid [match], expected one of: status, rstatus, string, rstring"); break; } } } foreach (var frontend in Frontends) { frontend.Validate(context, this); } foreach (var backend in Backends) { backend.Validate(context, this); } // Verify that the port/host combinations are unique for each frontend. var frontendMap = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var frontend in Frontends) { if (string.IsNullOrEmpty(frontend.PathPrefix)) { var key = $"{frontend.Host}:{frontend.ProxyPort}"; if (frontendMap.Contains(key)) { context.Error($"HTTP rule [{Name}] includes two or more frontends that map to [{key}]."); } frontendMap.Add(key); } } foreach (var frontend in Frontends) { if (!string.IsNullOrEmpty(frontend.PathPrefix)) { var key = $"{frontend.Host}:{frontend.ProxyPort}{frontend.PathPrefix}"; if (frontendMap.Contains($"{frontend.Host}:{frontend.ProxyPort}") || // Ensure there's no *all* path frontend frontendMap.Contains(key)) { context.Error($"HTTP rule [{Name}] includes two or more frontends that map to [{key}]."); } frontendMap.Add(key); } } if (Cache != null && Cache.Enabled) { Cache.Validate(context, this); // The Varnish open source release doesn't support TLS backends. This requires // Varnish Plus (of course) which is very expensive. foreach (TrafficHttpBackend backend in Backends) { if (backend.Tls) { context.Error($"HTTP rule [{Name}] cannot support caching because one or more backends required TLS."); break; } } // Varnish doesn't support comparing health probe status codes with a regex // like HAProxy does. We're going to enforce having CheckExpect set to // something like "status 200". var statusFields = CheckExpect.Split(' '); if (statusFields.Length != 2 || statusFields[0] != "status" || !int.TryParse(statusFields[1], out var statusCode) || statusCode < 100 || 600 <= statusCode) { context.Error($"HTTP rule [{Name}] cannot support caching because [{nameof(CheckExpect)}={CheckExpect}] doesn't specify a fixed status code like [status 200]. Varnish-Cache does not support verifying health probe status codes as regular expressions like HAProxy can."); } // $todo(jeff.lill): // // We need to enforce some restrictions due to Varnish limitations // described here: // // https://github.com/jefflill/NeonForge/issues/379 // // It would be nice to revisit this in the future. // Ensure that: // // * If one backend has a hostname then it must be the only backend. // * IP address and hostname backends cannot be mixed. if (Backends.Count > 1) { var hasHostname = false; var hasIPAddress = false; foreach (var backend in Backends) { if (IPAddress.TryParse(backend.Server, out var address)) { hasIPAddress = true; } else { hasHostname = true; } } if (hasIPAddress) { context.Error($"HTTP rule [{Name}] has multiple backends reachable via hostname which is not supported. You may define only a single backend that requires a DNS lookup."); } else if (hasIPAddress && hasHostname) { context.Error($"HTTP rule [{Name}] has backends reachable via IP address and hostname which is not supported. You cannot mix backends with IP address and hostnames in the same rule."); } } // Ensure that all cache warming targets have schemes, hostnames, ports that // match a rule frontend, and that HTTP rules don't map to reserved HTTPS ports // and HTTPS rules don't map to reserved HTTP ports. foreach (var frontend in Frontends) { if (frontend.Tls) { if (frontend.ProxyPort == HiveHostPorts.ProxyPublicHttp || frontend.ProxyPort == HiveHostPorts.ProxyPrivateHttp) { context.Error($"Rule [{Name}] has an HTTPS frontend with [{nameof(frontend.ProxyPort)}={frontend.ProxyPort}] that is incorrectly mapped to a reserved HTTP port."); } } else { if (frontend.ProxyPort == HiveHostPorts.ProxyPublicHttps || frontend.ProxyPort == HiveHostPorts.ProxyPrivateHttps) { context.Error($"Rule [{Name}] has an HTTP frontend with [{nameof(frontend.ProxyPort)}={frontend.ProxyPort}] that is incorrectly mapped to a reserved HTTPS port."); } } } // Ensure that all cache warming targets have schemes, hostnames, and ports that // match a rule frontend. foreach (var warmTarget in Cache.WarmTargets) { var uri = new Uri(warmTarget.Uri); var tls = uri.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase); if (Frontends.IsEmpty(fe => fe.Tls == tls && fe.Host.Equals(uri.Host, StringComparison.InvariantCultureIgnoreCase) && fe.ProxyPort == uri.Port)) { context.Error($"Cache warm target [{uri}] does not match one of the [{Name}] traffic manager frontends."); } } } }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.Subtract); if (Sse2.IsSupported) { using (var doubleTable = TestTableSse2 <double> .Create(testsCount)) using (var longTable = TestTableSse2 <long> .Create(testsCount)) using (var ulongTable = TestTableSse2 <ulong> .Create(testsCount)) using (var intTable = TestTableSse2 <int> .Create(testsCount)) using (var uintTable = TestTableSse2 <uint> .Create(testsCount)) using (var shortTable = TestTableSse2 <short> .Create(testsCount)) using (var ushortTable = TestTableSse2 <ushort> .Create(testsCount)) using (var sbyteTable = TestTableSse2 <sbyte> .Create(testsCount)) using (var byteTable = TestTableSse2 <byte> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>, Vector128 <double>)value = doubleTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); doubleTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <long>, Vector128 <long>, Vector128 <long>)value = longTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); longTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <ulong>, Vector128 <ulong>, Vector128 <ulong>)value = ulongTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); ulongTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <int>, Vector128 <int>, Vector128 <int>)value = intTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); intTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <uint>, Vector128 <uint>, Vector128 <uint>)value = uintTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); uintTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <short>, Vector128 <short>, Vector128 <short>)value = shortTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); shortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <ushort>, Vector128 <ushort>, Vector128 <ushort>)value = ushortTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); ushortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <sbyte>, Vector128 <sbyte>, Vector128 <sbyte>)value = sbyteTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); sbyteTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <byte>, Vector128 <byte>, Vector128 <byte>)value = byteTable[i]; var result = Sse2.Subtract(value.Item1, value.Item2); byteTable.SetOutArray(result); } CheckMethod <double> checkDouble = (double x, double y, double z, ref double a) => (a = x - y) == z; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x - y) == z", checkDouble); testResult = Fail; } CheckMethod <long> checkLong = (long x, long y, long z, ref long a) => (a = x - y) == z; if (!longTable.CheckResult(checkLong)) { PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x - y) == z", checkLong); testResult = Fail; } CheckMethod <ulong> checkUlong = (ulong x, ulong y, ulong z, ref ulong a) => (a = x - y) == z; if (!longTable.CheckResult(checkLong)) { PrintError(ulongTable, methodUnderTestName, "(ulong x, ulong y, ulong z, ref ulong a) => (a = x - y) == z", checkUlong); testResult = Fail; } CheckMethod <int> checkInt32 = (int x, int y, int z, ref int a) => (a = x - y) == z; if (!intTable.CheckResult(checkInt32)) { PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x - y) == z", checkInt32); testResult = Fail; } CheckMethod <uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = x - y) == z; if (!uintTable.CheckResult(checkUInt32)) { PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x - y) == z", checkUInt32); testResult = Fail; } CheckMethod <short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x - y)) == z; if (!shortTable.CheckResult(checkInt16)) { PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x - y)) == z", checkInt16); testResult = Fail; } CheckMethod <ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x - y)) == z; if (!ushortTable.CheckResult(checkUInt16)) { PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x - y)) == z", checkUInt16); testResult = Fail; } CheckMethod <sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x - y)) == z; if (!sbyteTable.CheckResult(checkSByte)) { PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x - y)) == z", checkSByte); testResult = Fail; } CheckMethod <byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)(x - y)) == z; if (!byteTable.CheckResult(checkByte)) { PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x - y)) == z", checkByte); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
private static T CreateAssertionComponent <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath) where T : ActionBase { AssertionComponent assertionComponent = gameObject.AddComponent <AssertionComponent>(); assertionComponent.checkMethods = checkOnMethods; T result = (T)(assertionComponent.Action = ScriptableObject.CreateInstance <T>()); assertionComponent.Action.go = gameObject; assertionComponent.Action.thisPropertyPath = propertyPath; configurator = assertionComponent; StackTrace stackTrace = new StackTrace(fNeedFileInfo: true); string fileName = stackTrace.GetFrame(0).GetFileName(); for (int i = 1; i < stackTrace.FrameCount; i++) { StackFrame frame = stackTrace.GetFrame(i); if (frame.GetFileName() != fileName) { string text = (assertionComponent.m_CreatedInFilePath = frame.GetFileName().Substring(Application.dataPath.Length - "Assets".Length)); assertionComponent.m_CreatedInFileLine = frame.GetFileLineNumber(); break; } } return(result); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.SubtractSaturate); if (Sse2.IsSupported) { using (var shortTable = TestTableSse2 <short> .Create(testsCount)) using (var ushortTable = TestTableSse2 <ushort> .Create(testsCount)) using (var sbyteTable = TestTableSse2 <sbyte> .Create(testsCount)) using (var byteTable = TestTableSse2 <byte> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <short>, Vector128 <short>, Vector128 <short>)value = shortTable[i]; var result = Sse2.SubtractSaturate(value.Item1, value.Item2); shortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <ushort>, Vector128 <ushort>, Vector128 <ushort>)value = ushortTable[i]; var result = Sse2.SubtractSaturate(value.Item1, value.Item2); ushortTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <sbyte>, Vector128 <sbyte>, Vector128 <sbyte>)value = sbyteTable[i]; var result = Sse2.SubtractSaturate(value.Item1, value.Item2); sbyteTable.SetOutArray(result); } for (int i = 0; i < testsCount; i++) { (Vector128 <byte>, Vector128 <byte>, Vector128 <byte>)value = byteTable[i]; var result = Sse2.SubtractSaturate(value.Item1, value.Item2); byteTable.SetOutArray(result); } CheckMethod <short> checkInt16 = (short x, short y, short z, ref short a) => { int value = (int)x - y; value = Math.Max(value, short.MinValue); value = Math.Min(value, short.MaxValue); a = (short)value; return(a == z); }; if (!shortTable.CheckResult(checkInt16)) { PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x - y)) == z", checkInt16); testResult = Fail; } CheckMethod <ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => { int value = (int)x - y; value = Math.Max(value, 0); value = Math.Min(value, ushort.MaxValue); a = (ushort)value; return(a == z); }; if (!ushortTable.CheckResult(checkUInt16)) { PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x & y)) == z", checkUInt16); testResult = Fail; } CheckMethod <sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => { int value = (int)x - y; value = Math.Max(value, sbyte.MinValue); value = Math.Min(value, sbyte.MaxValue); a = (sbyte)value; return(a == z); }; if (!sbyteTable.CheckResult(checkSByte)) { PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x & y)) == z", checkSByte); testResult = Fail; } CheckMethod <byte> checkByte = (byte x, byte y, byte z, ref byte a) => { int value = (int)x - y; value = Math.Max(value, 0); value = Math.Min(value, byte.MaxValue); a = (byte)value; return(a == z); }; if (!byteTable.CheckResult(checkByte)) { PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x & y)) == z", checkByte); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
public static bool CheckValidChar(string s, CheckMethod cm = CheckMethod.None) { if (string.IsNullOrWhiteSpace(s)) return false; string sm = ""; switch (cm) { default: case CheckMethod.None: return true; case CheckMethod.CharNum: sm = "[0-9a-zA-Z]"; break; case CheckMethod.CharNumBlank: sm = "[0-9a-zA-Z ]"; break; case CheckMethod.Char: sm = "[a-zA-Z]"; break; case CheckMethod.Num: sm = "[0-9.]"; break; case CheckMethod.Tel: sm = "[0-9-()]"; break; } Regex reg = new Regex(sm); int len = s.Length; for (int i = 0; i < len; i++) { string c = s.Substring(i, 1); if (reg.Match(c).Success == false) return false; } return true; }