Advertisement
amsavchenko

Untitled

Sep 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.20 KB | None | 0 0
  1. void TestArraySequence() {
  2.     cout << "--- НАЧАЛО ТЕСТИРОВАНИЯ (с массивами) ---" << endl;
  3.     ArraySequence<int> testArray;
  4.    
  5.     if (testArray.getLength() == 0) cout << "Тест 1 - OK" << endl;
  6.     else cout << "Тест 1 - Mistake" << endl;
  7.    
  8.     testArray.Append(23);
  9.     testArray.PrintAll();
  10.    
  11.     if (testArray.getLength() == 1) cout << "Тест 2 - OK" << endl;
  12.     else cout << "Тест 2 - Mistake" << endl;
  13.    
  14.     if (testArray.GetFirst() == 23) cout << "Тест 3 - OK" << endl;
  15.     else cout << "Тест 3 - Mistake" << endl;
  16.    
  17.     if (testArray.GetLast() == 23) cout << "Тест 4 - OK" << endl;
  18.     else cout << "Тест 4 - Mistake" << endl;
  19.    
  20.     try {
  21.         if (testArray.Get(0) == 23) cout << "Тест 5 - OK" << endl;
  22.         else cout << "Тест 5 - Mistake" << endl;
  23.     }
  24.     catch (ExceptionOutOfBounds ex){
  25.         ex.what();
  26.     }
  27.    
  28.     try {
  29.         cout << testArray.Get(-1) << endl;
  30.     }
  31.     catch (ExceptionOutOfBounds ex){
  32.         ex.what();
  33.     }
  34.    
  35.     try {
  36.         testArray.Get(1);
  37.     }
  38.     catch (ExceptionOutOfBounds ex){
  39.         ex.what();
  40.     }
  41.    
  42.     testArray.Append(43);
  43.     testArray.PrintAll();
  44.    
  45.     if (testArray.getLength() == 2) cout << "Тест 6 - OK" << endl;
  46.     else cout << "Тест 6 - Mistake" << endl;
  47.    
  48.     if (testArray.GetFirst() == 23) cout << "Тест 7 - OK" << endl;
  49.     else cout << "Тест 7 - Mistake" << endl;
  50.    
  51.     if (testArray.GetLast() == 43) cout << "Тест 8 - OK" << endl;
  52.     else cout << "Тест 8 - Mistake" << endl;
  53.    
  54.     try {
  55.         if (testArray.Get(0) == 23) cout << "Тест 9 - OK" << endl;
  56.         else cout << "Тест 9 - Mistake" << endl;
  57.     }
  58.     catch (ExceptionOutOfBounds ex){
  59.         ex.what();
  60.     }
  61.    
  62.     try {
  63.         if (testArray.Get(1) == 43) cout << "Тест 10 - OK" << endl;
  64.         else cout << "Тест 10 - Mistake" << endl;
  65.     }
  66.     catch (ExceptionOutOfBounds ex){
  67.         ex.what();
  68.     }
  69.    
  70.     try {
  71.         testArray.Get(-1);
  72.     }
  73.     catch (ExceptionOutOfBounds ex){
  74.         ex.what();
  75.     }
  76.    
  77.     try {
  78.         testArray.Get(2);
  79.     }
  80.     catch (ExceptionOutOfBounds ex){
  81.         ex.what();
  82.     }
  83.    
  84.     testArray.Prepend(53);
  85.     testArray.PrintAll();
  86.    
  87.     if (testArray.getLength() == 3) cout << "Тест 11 - OK" << endl;
  88.     else cout << "Тест 11 - Mistake" << endl;
  89.    
  90.     if (testArray.GetFirst() == 53) cout << "Тест 12 - OK" << endl;
  91.     else cout << "Тест 12 - Mistake" << endl;
  92.    
  93.     if (testArray.GetLast() == 43) cout << "Тест 13 - OK" << endl;
  94.     else cout << "Тест 13 - Mistake" << endl;
  95.    
  96.     try {
  97.         if (testArray.Get(0) == 53) cout << "Тест 14 - OK" << endl;
  98.         else cout << "Тест 14 - Mistake" << endl;
  99.     }
  100.     catch (ExceptionOutOfBounds ex){
  101.         ex.what();
  102.     }
  103.    
  104.     try {
  105.         if (testArray.Get(1) == 23) cout << "Тест 15 - OK" << endl;
  106.         else cout << "Тест 15 - Mistake" << endl;
  107.     }
  108.     catch (ExceptionOutOfBounds ex){
  109.         ex.what();
  110.     }
  111.    
  112.     try {
  113.         testArray.Get(-1);
  114.     }
  115.     catch (ExceptionOutOfBounds ex){
  116.         ex.what();
  117.     }
  118.    
  119.     try {
  120.         testArray.Get(3);
  121.     }
  122.     catch (ExceptionOutOfBounds ex){
  123.         ex.what();
  124.     }
  125.    
  126.    
  127.     ArraySequence<int> testSubseq = testArray.GetSubsequence(1, 1);
  128.    
  129.     if (testSubseq.getLength() == 1) cout << "Тест 16 - OK" << endl;
  130.     else cout << "Тест 16 - Mistake" << endl;
  131.    
  132.     if (testSubseq.GetFirst() == 23) cout << "Тест 17 - OK" << endl;
  133.     else cout << "Тест 17 - Mistake" << endl;
  134.    
  135.     if (testSubseq.GetLast() == 23) cout << "Тест 18 - OK" << endl;
  136.     else cout << "Тест 18 - Mistake" << endl;
  137.    
  138.     testSubseq.PrintAll();
  139.    
  140.     testSubseq.InsertAt(0, 1);
  141.     testSubseq.InsertAt(2, 3);
  142.     testSubseq.InsertAt(2, 5);
  143.     testSubseq.PrintAll();
  144.     if (testSubseq.getLength() == 4) cout << "Тест 19 - OK" << endl;
  145.     else cout << "Тест 19 - Mistake" << endl;
  146.    
  147.    
  148.    
  149.     cout << "--- КОНЕЦ ТЕСТИРОВАНИЯ (с массивами) ---" << endl;
  150.    
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement