// ==++== // // // Copyright (c) 2002 Microsoft Corporation. All rights reserved. // // The use and distribution terms for this software are contained in the file // named license.txt, which can be found in the root of this distribution. // By using this software in any fashion, you are agreeing to be bound by the // terms of this license. // // You must not remove this notice, or any other, from this software. // // // ==--== using System.IO; using System; using System.Globalization; using GenStrings; using System.Text; public class Co2345Replace_cc { static String strName = "String.Replace(char)"; static String strTest = "Co2345Replace_cc"; static String strPath = ""; static int iCountErrors = 0; static int iCountTestcases = 0; const int MAXRANDOMSTRING = 100; const int MAXUNICODE = 65535; const int MINUNICODE = 0; const int CHARINSTRPERCENTAGE = 80; private Boolean runTest(double timeInterval, int repetitions) { try { String emptyString=""; emptyString=emptyString.Replace ('r', 't'); IntlStrings intl = new IntlStrings(); String testingString = intl.GetString(7, true, true); String copyTestString = testingString; Char charVar = testingString[4]; testingString = testingString.Replace(testingString[4], 'h'); testString(copyTestString, testingString, copyTestString[4], 'h', "Rep_cc-1"); testString ("Yehia", "Ye7ia", 'h', '7', "Rep_cc00"); iCountTestcases++; testString ("Redmond", "Redmond", 'x', 'd', "Rep_cc01"); testString ("Redmond", "Redmond", 'd', 'd', "Rep_cc02"); iCountTestcases++; iCountTestcases++; testString ("Redmond", "redmond", 'R', 'r', "Rep_cc03"); testString ("Redmond", "Redmond", 'r', 'c', "Rep_cc04"); testString ("Redmond", "Re mon ", 'd', ' ', "Rep_cc05"); iCountTestcases++; testString ("Reddod", "Rexxox", 'd', 'x', "Rep_cc06"); testString ("Redmo", "Rexmo", 'd', 'x', "Rep_cc07"); iCountTestcases++; testString ("Null", "N"+'\u0000'+"ll", 'u', '\u0000', "Rep_cc08"); testString ("In", "I"+'\uFFFF', 'n', '\uFFFF', "Rep_cc09"); testString (" ", " ", ' ', ' ', "Rep_cc10"); testString (" ", "aa", ' ', 'a', "Rep_cc11"); testString ("Seattle", "Sea"+'\n'+'\n'+"le", 't', '\n', "Rep_cc12"); testString ("Seattle", "Sea"+'\r'+'\r'+"le", 't', '\r', "Rep_cc13"); testString ("Seattle", "Sea"+'\t'+'\t'+"le", 't', '\t', "Rep_cc14"); testString ("Seattle", "Sea"+'\\'+'\\'+"le", 't', '\\', "Rep_cc15"); testString ("Seattle", "Sea"+'\a'+'\a'+"le", 't', '\a', "Rep_cc16"); testString ("Seattle", "Sea"+'\0'+'\0'+"le", 't', '\0', "Rep_cc17"); for (int index=0; indexdtStop) break; String randStrOld= GetRandomString(randStr, randChar); char randCharOld='a'; for (int charInStr=0; ; charInStr++) { dtCurrent=DateTime.Now; if (dtCurrent>dtStop) break; String randStrNew= randStrOld; String originalString=randStrOld; int randIndex=randIndexGen.Next(0, randStrOld.Length-1); if (charInStr100) charInStr=0; } } } private String MyReplace (String randStrNew, Char randCharOld, Char randCharNew) { for (int index=0; index=1) timeInSecs=Convert.ToInt64(args[0]); if (args.Length>=2) numOfReps = Convert.ToInt32(args[1]); } catch (System.FormatException) { Console.WriteLine ("INVALID ARGUMENTS"); Console.WriteLine ("USING DEFAULT: Co2345Replace_cc.exe 2 2 "); timeInSecs=2.0; numOfReps=2; } catch ( Exception exc ) { Console.WriteLine( "Error_abc637: Conversion error about input args?" ); Console.WriteLine( exc.ToString() ); goto LABEL_842_RETURN_LABEL; } try { Console.WriteLine( "RUNNING: Co2345Replace_cc.exe "+ timeInSecs+" "+ numOfReps); bResult = oReplaceTest.runTest(timeInSecs, numOfReps); } catch ( Exception exc_main ) { bResult = false; String strInfo = "Unexpected Exception: (runTest)" ; strInfo = strInfo + exc_main.ToString() ; Console.Error.WriteLine (strName+" "+strTest+" "+strPath); Console.Error.WriteLine (strInfo); } LABEL_842_RETURN_LABEL:; if ( ! bResult ) Console.Error.WriteLine( "PATHTOSOURCE: " + strPath + strTest + " FAIL" ); if ( bResult == true ) Environment.ExitCode = 0; else Environment.ExitCode = 11; } }