Tests/src/ErrorFile.cs
/// <summary>
/// Takes error description from a text file.
/// The format of the text file is a list of lines of the form:
/// line, column, type
/// </summary>
/// <param name="fileNames">The names of the file</param>
/// <returns>The list of expected errors</returns>
Takes error description from a text file.
The format of the text file is a list of lines of the form:
line, column, type
Takes error description from a text file . The format of the text file is a list of lines of the form : line column type
private static IList<ErrorDescription> ExpectedErrors(IList<string> fileNames) {
            IList<ErrorDescription> errors = new List<ErrorDescription>();
            foreach (string fileName in fileNames) {
                TextReader tr = new StreamReader(fileName);
                if (tr == null)
                    return null;
                string input;
                do {
                    input = tr.ReadLine();
                    if (input != null) {
                        char[] separators = { ',' };
                        string[] values = input.Split(separators);
                        int line, column;
                        string type;
                        try {
                            line = Convert.ToInt32(values[0]);
                        } catch (Exception) {
                            line = 0;
                        }
                        try {
                            column = Convert.ToInt32(values[1]);
                        } catch (Exception) {
                            column = 0;
                        }
                        try {
                            type = values[2].Trim();
                        } catch (Exception) {
                            type = "";
                        }
                        errors.Add(new ErrorDescription(line, column, type));
                    }
                } while (input != null);
                tr.Close();
            }
            return errors;
        }
private static IList < ErrorDescription > ExpectedErrors ( IList < string > fileNames ) { IList < ErrorDescription > errors = new List < ErrorDescription > ( ) ; foreach ( string fileName in fileNames ) { TextReader tr = new StreamReader ( fileName ) ; if ( tr == null ) return null ; string input ; do { input = tr . ReadLine ( ) ; if ( input != null ) { char [ ] separators = { ' ' } ; string [ ] values = input . Split ( separators ) ; int line , column ; string type ; try { line = Convert . ToInt32 ( values [ 0 ] ) ; } catch ( Exception ) { line = 0 ; } try { column = Convert . ToInt32 ( values [ 1 ] ) ; } catch ( Exception ) { column = 0 ; } try { type = values [ 2 ] . Trim ( ) ; } catch ( Exception ) { type = " " ; } errors . Add ( new ErrorDescription ( line , column , type ) ) ; } } while ( input != null ) ; tr . Close ( ) ; } return errors ; }
Takes error description from a text file.
Takes error description from a text file .
The list of expected errors
The list of expected errors
fileNames
IList<string>
The names of the file
The names of the file