HepMC3 event record library
HepMC3TestUtils.h
1 #include <iostream>
2 #include <fstream>
3 #include <stdio.h>
4 #include <string.h>
5 
6 int skip(const std::string& s1)
7 {
8  if (s1.length()==0) return 1;
9  if (s1.find("HepMC::Version")!=std::string::npos) return 1;
10  return 0;
11 }
12 int COMPARE_ASCII_FILES(const std::string& f1,const std::string& f2)
13 {
14  std::fstream file1(f1.c_str()), file2(f2.c_str());
15  std::string string1, string2;
16  int j1,j2;
17  j1 = 0;
18  j2 = 0;
19  std::cout <<"Run comparison"<< "\n";
20  while((!file1.eof())&&(!file2.eof()))
21  {
22  for (;;) {
23  j1++;
24  if (!std::getline(file1,string1)) break;
25  if (skip(string1)==0) break;
26  }
27  for (;;) {
28  j2++;
29  if (!std::getline(file2,string2)) break;
30  if (skip(string2)==0) break;
31  }
32 
33  if(string1.compare(string2) != 0)
34  {
35  std::cout << j1<<"/"<<j2 << "-th strings are not equal" << f1<<f2<<"\n";
36  std::cout << " ->" << string1 << "<-\n";
37  std::cout << " ->" << string2 << "<-\n";
38  return 1;
39  }
40  }
41  return 0;
42 }
43 
44 
45 
46 
47 
48 
49 
50 
51 
52