aboutsummaryrefslogtreecommitdiff
path: root/tests/tdiff.cpp
blob: 4be14fed6e48780bab3a4c2785082703b51aaeb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Windows does not have unix diff so this is a simple replacement
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[] ) {
  int rc=-1;
  if (argc != 3) {
      cout << "usage: " << argv[0] << " file1 file2\n";
      return -1;
  }
  char *file1 = argv[1];
  char *file2 = argv[2];
  ifstream is1(file1, ios::in);
  ifstream is2(file2, ios::in);
  if (is1.fail()) {cerr << "failed to open " << file1 << "\n"; goto done;}
  if (is2.fail()) {cerr << "failed to open " << file2 << "\n"; goto done;}
  char d1[256], d2[256];
  do {
    is1.read(d1,sizeof(d1));
    is2.read(d2,sizeof(d2));
    if ((is1.gcount() != is2.gcount()) || memcmp(d1,d2,is1.gcount())) {
        cout << file1 << " and " << file2 << " differ\n";
        goto done;
    }
  } while (!is1.eof() && !is2.eof());

  rc=0;

 done:
  is1.close();
  is2.close();
  return rc;
}