Advertisement
KiK0S

Untitled

Apr 30th, 2018
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4.  
  5. void gen(ofstream &out){
  6.     /*
  7.         here i just generate test
  8.     */
  9.     int n = 1e5;
  10.     out << n << '\n';
  11.     vector<int> q(n);
  12.     for(int i = n - 1; i >= 0; i--){
  13.         q[i] = rand();
  14.     }
  15.     for(int i = 0; i < n; i++){
  16.         out << q[i] << ' ';
  17.     }
  18.     out.close();
  19. }
  20.  
  21. /*
  22.     these two paths should go to already compiled exe-files
  23. */
  24. const string STUPID_EXE = "C:\\Users\\KiKoS\\Desktop\\CB\\Stress\\bin\\Debug\\Stupid.exe";
  25. const string CLEVER_EXE = "C:\\Users\\KiKoS\\Desktop\\CB\\Stress\\bin\\Debug\\Clever.exe";
  26.  
  27. /*
  28.     I use files to send info between programs. so i use freopen in solutions and ifstreams in stress
  29.     also you can send info using smth like system(kek.exe < test.txt)
  30. */
  31. const string INPUT = "C:\\Users\\KiKoS\\Desktop\\CB\\Stress\\test.txt";
  32. const string STUPID_OUTPUT = "C:\\Users\\KiKoS\\Desktop\\CB\\Stress\\stupid.txt";
  33. const string CLEVER_OUTPUT = "C:\\Users\\KiKoS\\Desktop\\CB\\Stress\\clever.txt";
  34.  
  35. signed main(){
  36.     srand(time(0));
  37.     int NUMTEST = 10;
  38.     for(int i = 0; i < NUMTEST; i++){
  39.         cout << i << endl;
  40.         ofstream out(INPUT);
  41.         gen(out);
  42.         system(STUPID_EXE);
  43.         system(CLEVER_EXE);
  44.         string ans1, ans2, tmp;
  45.         ifstream in1(STUPID_OUTPUT);
  46.         ifstream in2(CLEVER_OUTPUT);
  47.         while(in1 >> tmp){
  48.             ans1 += "\n";
  49.             ans1 += tmp;
  50.         }
  51.         in1.close();
  52.         while(in2 >> tmp){
  53.             ans2 += "\n";
  54.             ans2 += tmp;
  55.         }
  56.         if(ans1 != ans2){
  57.             cout << "ERROR";
  58.             /*
  59.                 wrong test is now in test.txt
  60.             */
  61.             break;
  62.         }
  63.     }
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement