public string[,] GetBaseChoiceTests(VariableBC[] varList) { int numInput = varList.Length; // number of inputs string[] baseValues = new string[numInput]; string[,] testCases; int k = 0, m = 0, q = 0; List<string>[] intervals = new List<string>[numInput]; // an array of lists, where each list contains all the values within the interval(s) for an input List<string> allValues; baseValues = getBaseValues(varList); // get all base values numTestCases = 0; for (int i = 0; i < numInput; i++) { intervals[i] = getAllFromIntervals(varList[i]); // all the values within the intervals, e.g. 2-5;7-9;17-19 -> (2,3,4,5,7,8,9,17,18,19) numTestCases = numTestCases + intervals[i].Count; //printListStr(intervals[i]); // test function just to print all the values within the intervals of a Variable } numTestCases = numTestCases - numInput + 1; // calculate the number of test cases testCases = new string[numTestCases, numInput]; // size of array which will contain the test cases, where each row is a test for (int i = 0; i < numInput; i++) // add the combination of all base values as the last test case { testCases[numTestCases - 1, i] = baseValues[i]; } // generate the base choice test cases for (int i = 0; i < numInput; i++) { allValues = getUniqueList(intervals[i]); // list of all the values within the interval(s) for an input (doesn't contain any duplicates) //printListStr(allValues); //System.Windows.Forms.MessageBox.Show("All values count: " + allValues.Count); for (int a = 0; a < allValues.Count; a++) { if (baseValues[i] != allValues.ElementAt(a)) { testCases[k, i] = allValues.ElementAt(a); k++; } } for (int j = 0; j < numInput; j++) { if (i != j) { for (m = q; m < k; m++) { testCases[m, j] = baseValues[j]; } } } q = m; } return testCases; }
private List <string> getAllFromIntervals(VariableBC v) // get all the values within the intervals from a variable to an array { switch (v.variable.datatype) { case "INT": return(getAllValues_Int(v.variable.intervals)); case "BOOL": return(getAllValues_Int(v.variable.intervals)); case "REAL": return(getAllValues_Float(v.variable.intervals)); default: List <string> s = new List <string>(); s.Add("Error"); return(s); } }
private string[] getBaseValues(VariableBC[] varList) { int numInputs = varList.Length; string[] baseValues = new string[numInputs]; for (int i = 0; i < numInputs; i++) { baseValues[i] = varList[i].baseChoice; } return baseValues; }
// get all the values within the intervals from a variable to an array private List<string> getAllFromIntervals(VariableBC v) { switch (v.variable.datatype) { case "INT": return getAllValues_Int(v.variable.intervals); case "BOOL": return getAllValues_Int(v.variable.intervals); case "REAL": return getAllValues_Float(v.variable.intervals); default: List<string> s = new List<string>(); s.Add("Error"); return s; } }