fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class Tester;
  5. class Tester2;
  6. class blackbox{
  7. public:
  8. friend class Tester;
  9. friend class Tester2;
  10. bool tes1(){
  11. return true;
  12. }
  13. bool tes2(){
  14. return true;
  15. //return false;
  16. }
  17. void testall(){
  18. tes1(),tes2();
  19. }
  20. };
  21. class Tester1 {
  22. public:
  23. blackbox obj;
  24.  
  25. void test() {
  26. cerr << "check tes1...\n";
  27. assert((obj.tes1()));
  28.  
  29. cerr << "check tes2...\n";
  30. assert((obj.tes2()) );
  31.  
  32. cerr << "All tests passed!\n";
  33. }
  34. };
  35. class Tester2{
  36. public:
  37. blackbox obj;
  38. void test(){
  39. if (!obj.tes1()) {
  40. cerr << "tes1 has a bug\n";
  41. assert(false);
  42. }
  43. else {
  44. cerr << "Test 1 works well\n";
  45. }
  46.  
  47. if (!obj.tes2()) {
  48. cerr << "tes2 has a bug\n";
  49. assert(false);
  50. }
  51. else {
  52. cerr << "Test 2 works well\n";
  53. }
  54. }
  55.  
  56. };
  57. int main(){
  58. Tester1 t;
  59. t.test();
  60. Tester2 t1;
  61. t1.test();
  62. return 0;
  63. }
Success #stdin #stdout #stderr 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
check tes1...
check tes2...
All tests passed!
Test 1 works well
Test 2 works well