-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
71 lines (63 loc) · 1.48 KB
/
main.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include "array.h"
#include <stdexcept>
using namespace std;
void arrayBracketsTest();
int main()
{
arrayBracketsTest();
Array<int, 3> my_ar = {4,5,6};
my_ar.Show();
cout << endl;
my_ar[1] = 7;
my_ar.Show();
cout << endl;
cout << my_ar[0] << endl;
return 0;
}
void arrayBracketsTest()
{
try
{
Array<int, 2> test_ar = {1,2};
int x = test_ar[0];
if (x != 1)
{
cout << __LINE__ << endl;
cout << "Test failed! Digital mismatch." << endl;
return;
}
test_ar[0] = 3;
int x2 = test_ar[0];
if (x2 != 3)
{
cout << __LINE__ << endl;
cout << "Test failed! Digital mismatch during reassigment." << endl;
return;
}
try
{
test_ar[345345] = 34;
cout << __LINE__;
cout << "Test failed! Assigment out of array size range." << endl;
return;
}
catch (invalid_argument &e)
{
cout << "Error occured: " << e.what() << endl;
cout << "Expected exception, valid case." << endl;
}
catch(...)
{
cout << "Unspecified exception occured." << endl;
return;
}
cout << "Test complete!" << endl;
}
catch(...)
{
cout << "Unspecified exception occured." << endl;
return;
}
cout << "Test complete!" << endl;
}