Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TestArraySequence() {
- cout << "--- НАЧАЛО ТЕСТИРОВАНИЯ (с массивами) ---" << endl;
- ArraySequence<int> testArray;
- if (testArray.getLength() == 0) cout << "Тест 1 - OK" << endl;
- else cout << "Тест 1 - Mistake" << endl;
- testArray.Append(23);
- testArray.PrintAll();
- if (testArray.getLength() == 1) cout << "Тест 2 - OK" << endl;
- else cout << "Тест 2 - Mistake" << endl;
- if (testArray.GetFirst() == 23) cout << "Тест 3 - OK" << endl;
- else cout << "Тест 3 - Mistake" << endl;
- if (testArray.GetLast() == 23) cout << "Тест 4 - OK" << endl;
- else cout << "Тест 4 - Mistake" << endl;
- try {
- if (testArray.Get(0) == 23) cout << "Тест 5 - OK" << endl;
- else cout << "Тест 5 - Mistake" << endl;
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- cout << testArray.Get(-1) << endl;
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- testArray.Get(1);
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- testArray.Append(43);
- testArray.PrintAll();
- if (testArray.getLength() == 2) cout << "Тест 6 - OK" << endl;
- else cout << "Тест 6 - Mistake" << endl;
- if (testArray.GetFirst() == 23) cout << "Тест 7 - OK" << endl;
- else cout << "Тест 7 - Mistake" << endl;
- if (testArray.GetLast() == 43) cout << "Тест 8 - OK" << endl;
- else cout << "Тест 8 - Mistake" << endl;
- try {
- if (testArray.Get(0) == 23) cout << "Тест 9 - OK" << endl;
- else cout << "Тест 9 - Mistake" << endl;
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- if (testArray.Get(1) == 43) cout << "Тест 10 - OK" << endl;
- else cout << "Тест 10 - Mistake" << endl;
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- testArray.Get(-1);
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- testArray.Get(2);
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- testArray.Prepend(53);
- testArray.PrintAll();
- if (testArray.getLength() == 3) cout << "Тест 11 - OK" << endl;
- else cout << "Тест 11 - Mistake" << endl;
- if (testArray.GetFirst() == 53) cout << "Тест 12 - OK" << endl;
- else cout << "Тест 12 - Mistake" << endl;
- if (testArray.GetLast() == 43) cout << "Тест 13 - OK" << endl;
- else cout << "Тест 13 - Mistake" << endl;
- try {
- if (testArray.Get(0) == 53) cout << "Тест 14 - OK" << endl;
- else cout << "Тест 14 - Mistake" << endl;
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- if (testArray.Get(1) == 23) cout << "Тест 15 - OK" << endl;
- else cout << "Тест 15 - Mistake" << endl;
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- testArray.Get(-1);
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- try {
- testArray.Get(3);
- }
- catch (ExceptionOutOfBounds ex){
- ex.what();
- }
- ArraySequence<int> testSubseq = testArray.GetSubsequence(1, 1);
- if (testSubseq.getLength() == 1) cout << "Тест 16 - OK" << endl;
- else cout << "Тест 16 - Mistake" << endl;
- if (testSubseq.GetFirst() == 23) cout << "Тест 17 - OK" << endl;
- else cout << "Тест 17 - Mistake" << endl;
- if (testSubseq.GetLast() == 23) cout << "Тест 18 - OK" << endl;
- else cout << "Тест 18 - Mistake" << endl;
- testSubseq.PrintAll();
- testSubseq.InsertAt(0, 1);
- testSubseq.InsertAt(2, 3);
- testSubseq.InsertAt(2, 5);
- testSubseq.PrintAll();
- if (testSubseq.getLength() == 4) cout << "Тест 19 - OK" << endl;
- else cout << "Тест 19 - Mistake" << endl;
- cout << "--- КОНЕЦ ТЕСТИРОВАНИЯ (с массивами) ---" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement