public void RecursionTest1() { var mydict = new MyDict <string, int>(); var result = mydict.ContainsKey("foo"); Assert.IsFalse(result); }
public bool CompareStringWithPrefixes(string strExpected) { MyDict <string, object> AutoIDs = new MyDict <string, object>(); List <string> AttNames = new List <string>(); List <string> AttScopes = new List <string>(); string strActual = this.GetString(); int expLen = (strExpected == null ? 0 : strExpected.Length); int actLen = (strActual == null ? 0 : strActual.Length); int minLen = (expLen < actLen ? expLen : actLen); // find the first different character int i, j = 0; for (i = 0; i < actLen; i++) { if (j >= expLen) { CError.WriteLine("Output longer than expected!"); CError.WriteLine("Actual string: '" + strActual + "'"); return(false); } if (strExpected[j] != strActual[i]) { if (strExpected[j] != PREFIX_CHAR) { CError.WriteLine("Position:" + i); CError.WriteLine("Expected char:'" + strExpected[i] + "'(" + Convert.ToInt32(strExpected[i]) + ")"); CError.WriteLine("Actual char:'" + strActual[i] + "'(" + Convert.ToInt32(strActual[i]) + ")"); return(false); } bool AutoGenerated = strExpected[++j] == AUTOGENERATED; j += 2; string ActName = ""; string ExpName = ""; string Scope = ""; while (i <= actLen) { if (strActual[i] == '=' || strActual[i] == ' ' || strActual[i] == ':') { i--; break; } else { ActName += strActual[i]; } i++; } while (strExpected[j] != ' ') { ExpName += strExpected[j++]; } j++; while (strExpected[j] != PREFIX_CHAR) { Scope += strExpected[j++]; } if (AutoGenerated) { if (AutoIDs.ContainsKey(ExpName)) { if ((string)AutoIDs[ExpName] != ActName) { CError.WriteLine("Invalid Prefix: '" + ActName + "'"); return(false); } } else { AutoIDs.Add(ExpName, ActName); } } else { if (ExpName != ActName) { CError.WriteLine("Invalid Prefix: '" + ActName + "'"); return(false); } } for (int k = 0; k < AttNames.Count; k++) { if ((string)AttNames[k] == ActName) { for (int m = 0; m < ((string)AttScopes[k]).Length; m++) { for (int n = 0; n < Scope.Length; n++) { if (((string)AttScopes[k])[m] == Scope[n]) { CError.WriteLine("Invalid Prefix: '" + ActName + "'"); return(false); } } } } } AttNames.Add(ActName); AttScopes.Add(Scope); } j++; } if (j != expLen) { CError.WriteLine("Output shorter than expected!"); CError.WriteLine("Actual string: '" + strActual + "'"); return(false); } return(true); }
public bool CompareStringWithPrefixes(string strExpected) { MyDict<string, object> AutoIDs = new MyDict<string, object>(); List<string> AttNames = new List<string>(); List<string> AttScopes = new List<string>(); string strActual = this.GetString(); int expLen = (strExpected == null ? 0 : strExpected.Length); int actLen = (strActual == null ? 0 : strActual.Length); int minLen = (expLen < actLen ? expLen : actLen); // find the first different character int i, j = 0; for (i = 0; i < actLen; i++) { if (j >= expLen) { CError.WriteLine("Output longer than expected!"); CError.WriteLine("Actual string: '" + strActual + "'"); return false; } if (strExpected[j] != strActual[i]) { if (strExpected[j] != PREFIX_CHAR) { CError.WriteLine("Position:" + i); CError.WriteLine("Expected char:'" + strExpected[i] + "'(" + Convert.ToInt32(strExpected[i]) + ")"); CError.WriteLine("Actual char:'" + strActual[i] + "'(" + Convert.ToInt32(strActual[i]) + ")"); return false; } bool AutoGenerated = strExpected[++j] == AUTOGENERATED; j += 2; string ActName = ""; string ExpName = ""; string Scope = ""; while (i <= actLen) { if (strActual[i] == '=' || strActual[i] == ' ' || strActual[i] == ':') { i--; break; } else { ActName += strActual[i]; } i++; } while (strExpected[j] != ' ') { ExpName += strExpected[j++]; } j++; while (strExpected[j] != PREFIX_CHAR) { Scope += strExpected[j++]; } if (AutoGenerated) { if (AutoIDs.ContainsKey(ExpName)) { if ((string)AutoIDs[ExpName] != ActName) { CError.WriteLine("Invalid Prefix: '" + ActName + "'"); return false; } } else { AutoIDs.Add(ExpName, ActName); } } else { if (ExpName != ActName) { CError.WriteLine("Invalid Prefix: '" + ActName + "'"); return false; } } for (int k = 0; k < AttNames.Count; k++) { if ((string)AttNames[k] == ActName) { for (int m = 0; m < ((string)AttScopes[k]).Length; m++) for (int n = 0; n < Scope.Length; n++) if (((string)AttScopes[k])[m] == Scope[n]) { CError.WriteLine("Invalid Prefix: '" + ActName + "'"); return false; } } } AttNames.Add(ActName); AttScopes.Add(Scope); } j++; } if (j != expLen) { CError.WriteLine("Output shorter than expected!"); CError.WriteLine("Actual string: '" + strActual + "'"); return false; } return true; }