source: trunk/yao/src/analyzers/automaticTestFilesGenerator/testGeneratedFiles.cpp @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1#include <string>
2#include <iostream>
3#include <sstream>
4#include <fstream>
5
6using namespace std;
7
8main(int argc, char *argv[]){
9  char line1[10000], line2[10000];
10  string strline1, strline2;
11  ostringstream ostr1, ostr2;
12  bool flag;
13  cout << "The first parameter: " << argv[1] << "\n";
14  cout << "The second parameter: " << argv[2] << "\n";
15  ifstream Y11(argv[1], ios::in | ios::binary);
16  ifstream Y12(argv[2], ios::in | ios::binary);
17  if(!Y11.is_open() || !Y12.is_open())
18     throw ofstream::failure("couldn't open ");
19 
20  //Y11.getline(line1,9000);
21 
22 
23  //  Y12.getline(line2,9000);
24//  getline(Y11, strline1);
25//cout << "You entered " << strline1 << endl;
26  //cout << "\nLetto: \n" << line1 << endl;
27 
28 
29  while(getline(Y11, strline1)){
30    flag = false;
31    //caso di lettura stringa vuota
32    if(strline1.size() == 0)
33      continue;
34    // For all the characters of the string
35    for(int i=0; i<strline1.size(); i++){
36      if(strline1[i] == '/' && strline1[i+1] == '*'){
37        flag = true;
38        continue;
39      }
40      if(flag){
41        if(strline1[i] == '*' && strline1[i+1] == '/'){
42        flag=false;
43        i++;
44        }
45        continue;
46      }
47      //if(strline1[i] == '/' && i<strline1.size()-1 && strline1[i+1] == '/')
48      // Comment case: "//"
49      if(strline1[i] == '/' && strline1[i+1] == '/'){
50        i = strline1.size() -1;
51        continue;
52      }
53      // Case space or tab
54      if(strline1[i] != ' ' && strline1[i] != '\t')
55        ostr1 << strline1[i];
56      //ostr1 << strline1;
57    }
58  }
59//  cout << "Letto1: " << ostr1.str() << endl;
60 
61 
62  while(getline(Y12, strline2)){
63    flag = false;
64    // Case read of empty string
65    if(strline2.size() == 0)
66      continue;
67    // For all the characters of the string
68    for(int i=0; i<strline2.size(); i++){
69      if(strline2[i] == '/' && strline2[i+1] == '*'){
70        flag = true;
71        continue;
72      }
73      if(flag){
74        if(strline2[i] == '*' && strline2[i+1] == '/'){
75        flag=false;
76        i++;
77        }
78        continue;
79      }
80      //if(strline1[i] == '/' && i<strline1.size()-1 && strline1[i+1] == '/')
81      // Comment case "//"
82      if(strline2[i] == '/' && strline2[i+1] == '/'){
83        i = strline2.size() -1;
84        continue;
85      }
86      // Case space or tab
87      if(strline2[i] != ' ' && strline2[i] != '\t')
88        ostr2 << strline2[i];
89    }
90  }
91 
92  //cout << "\n\nLetto2: " << ostr1.str() << endl;
93
94  string str = ostr2.str();
95  str.erase(ostr1.str().size()); // Erase all after
96
97  cout << "size string1: " << ostr1.str().size() << endl;
98  cout << "size string2: " << str.size() << endl;
99
100  //if(ostr1.str() != ostr2.str())
101  if(ostr1.str() != str){
102    cout << "Error!!!!!!!  ";
103    for(int i=0; i<str.size(); i++){
104        if(ostr1.str()[i] != str[i]){
105          cout << "Number of letter already reed? :" << i << endl;
106          str.erase(0, i);
107          cout << str;
108          break;
109        }
110    }
111  }else cout << "Everything ok: FILES ARE EQUAL\n";
112}
113
114
Note: See TracBrowser for help on using the repository browser.