Co5568Peek.runTest C# (CSharp) Method

runTest() public method

public runTest ( ) : bool
return bool
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		String strValue = String.Empty;
		try
		{
			StringReader sr;
			Int32 i32;
			String str1;
			strLoc = "Loc_98yg7";
            iCountTestcases++;
            try{
                sr = new StringReader(null);
                i32 = sr.Peek();
                iCountErrors++;
                printerr( "Error_198yz! Incorrect value returned, i32=="+i32);
            }catch( ArgumentNullException e ){
                printinfo("Expected exception occured" + e.Message);
            }catch(Exception e ){
                iCountErrors++;
                printerr("Err_3255!! Unexpected exception occured... " + e.ToString() );
            }
			strLoc = "Loc_4790s";
			sr = new StringReader(String.Empty);
			iCountTestcases++;
			i32 = sr.Peek();
			if(i32 != -1) {
				iCountErrors++;
				printerr( "Error_099xa! Incorrect value returned, i32=="+i32);
			} 
			strLoc = "Loc_8388x";
			str1 = "Hello\0\t\v   \\ World";
			sr = new StringReader(str1);
			for(int i = 0 ; i < str1.Length ; i++) {
				iCountTestcases++;
				i32 = sr.Peek();
				sr.Read();
				if(i32 != (Int32)str1[i]) {
					iCountErrors++;
					printerr( "Error_198x9! Expected=="+(Int32)str1[i]+" , got=="+i32);
				}
			} 
			strLoc = "Loc_298xy";
			str1 = String.Empty;
			Random r = new Random((Int32)DateTime.Now.Ticks);
			for(int i = 0 ; i < 5000 ; i++)
				str1 += (Char)r.Next(0,255);
			sr = new StringReader(str1);
			for(int i = 0 ; i < str1.Length ; i++) {
				iCountTestcases++;
				i32 = sr.Peek();
				sr.Read();
				if(i32 != (Int32)str1[i]) {
					iCountErrors++;
					printerr( "Error_109ux! Expected=="+(Int32)str1[i]+" , got=="+i32);
				}
			}
		} catch (Exception exc_general ) {			
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
	public void printerr ( String err )

Usage Example

Example #1
0
    public static void Main(String[] args)
    {
        bool       bResult = false;
        Co5568Peek cbA     = new Co5568Peek();

        try {
            bResult = cbA.runTest();
        } catch (Exception exc_main) {
            bResult = false;
            Console.WriteLine(s_strTFAbbrev + " : FAiL! Error Err_9999zzz! Uncaught Exception in main(), exc_main==" + exc_main.ToString());
        }
        if (!bResult)
        {
            Console.WriteLine("Path: " + s_strTFName + s_strTFPath);
            Console.WriteLine(" ");
            Console.WriteLine("FAiL!  " + s_strTFAbbrev);
            Console.WriteLine(" ");
        }
        if (bResult)
        {
            Environment.ExitCode = 0;
        }
        else
        {
            Environment.ExitCode = 1;
        }
    }
All Usage Examples Of Co5568Peek::runTest