// ==++== // // // 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.Text; using System.Globalization; using GenStrings; public class Co2346Replace_ss { static String strName = "String.Replace(String)"; static String strTest = "Co2346Replace_ss"; static String strPath = ""; static int iCountErrors = 0; static int iCountTestcases = 0; const int MAXRANDOMSTRING = 90; const int MAXUNICODE = 65535; const int MINUNICODE = 0; const int CHARINSTRPERCENTAGE = 100; public Boolean runTest(double timeInterval, int repetitions) { try { try { String trialStr = "asdf"; trialStr=trialStr.Replace (null, null); iCountErrors++; Console.WriteLine( "Error_num701: Should have thrown." ); } catch (System.ArgumentNullException) { } try { IntlStrings intl = new IntlStrings(); String trialStr = intl.GetString(18, false, true); trialStr=trialStr.Replace (null ,"s"); iCountErrors++; Console.WriteLine( "Error_nuz801: Should have thrown." ); } catch (System.ArgumentNullException) { } try { String trialStr = "asdf"; trialStr=trialStr.Replace (null ,"s"); iCountErrors++; Console.WriteLine( "Error_nuz801: Should have thrown." ); } catch (System.ArgumentNullException) { } testString ("asdf", "adf", "s", null, "Rep_ss200"); testString ("Yehia", "Ye7ia", "h", "7", "Rep_ss00"); testString ("Redmond", "Redmond", "x", "d", "Rep_ss01"); testString ("Redmond", "Redmond", "d", "d", "Rep02"); testString ("Redmond", "redmond", "R", "r", "Rep_ss03"); testString ("Redmond", "Redmond", "r", "c", "Rep_ss04"); iCountTestcases++; testString ("Redmond", "Re mon ", "d", " ", "Rep_ss05"); iCountTestcases++; testString ("Reddod", "Rexxox", "d", "x", "Rep_ss06"); iCountTestcases++; testString ("Redmo", "Rexmo", "d", "x", "Rep_ss07"); iCountTestcases++; testString ("Null", "N"+'\u0000'+"ll", "u", "\u0000", "Rep_ss08"); iCountTestcases++; testString ("In", "I"+'\uFFFF', "n", "\uFFFF", "Rep_ss09"); iCountTestcases++; testString (" ", " ", " ", " ", "Rep_ss10"); iCountTestcases++; testString (" ", "aa", " ", "a", "Rep_ss11"); testString ("Seattle", "Sea\\n\\nle", "t", "\\n", "Rep_ss12"); iCountTestcases++; testString ("Seattle", "Sea\\r\\rle", "t", "\\r", "Rep_ss13"); testString ("Seattle", "Sea\\t\\tle", "t", "\\t", "Rep_ss14"); testString ("Seattle", "S\\attl\\", "e", "\\", "Rep_ss15"); testString ("Seattle", "Sea\\a\\ale", "t", "\\a", "Rep_ss16"); testString ("Seattle", "Sea\\0\\0le", "t", "\\0", "Rep_ss17"); testString ("", "", "f", "s", "Rep_ss18"); testString ("asdf", "asdss", "f", "ss", "Rep_ss19"); testString ("asdf", "asdf", "ss", "f", "Rep_ss20"); testString (" ", "asdf", " ", "asdf", "Rep_ss21"); testString ("as ", "ax ", "s", "x", "Rep_ss22"); testString (" ", " ", "x", "a", "Rep_ss23"); testString ("ss", "ssss", "s", "ss", "Rep_ss24"); testString ("sdsd", "", "sd", "", "Rep_ss25"); testString (" ", "a ", " ", "a", "Rep_ss26"); testString ("sf", "sc", "f", "c", "Rep_ss25"); testString ("sfff", "scc", "fff", "cc", "Rep_ss25"); String point=" "; String other=point; testString (point, other, " ", " ", "Rep_ss27"); testString ("asdf", "asdf", "dfgg", "vb", "Rep_ss28"); for (int index=0; indexdtStop) break; String originalString = getRandomString(randStr, randChar); String oldValue = ""; for (int strInStr=0; ; strInStr++) { dtCurrent=DateTime.Now; if (dtCurrent>dtStop) break; String newValue = getRandomString(randStr, randChar); if (strInStr10) break; } StringBuilder sbStr = new StringBuilder (maxString); 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: Co2346Replace_ss.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_882_RETURN_LABEL; } try { 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_882_RETURN_LABEL:; if ( ! bResult ) Console.Error.WriteLine( "PATHTOSOURCE: " + strPath + strTest + " FAIL" ); if ( bResult == true ) Environment.ExitCode = 0; else Environment.ExitCode = 11; } }