-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (55 loc) · 1.36 KB
/
Copy pathmain.cpp
File metadata and controls
65 lines (55 loc) · 1.36 KB
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
#include <iostream>
#include <vector>
#include "Span.hpp"
int main(void)
{
std::cout << "Test sujet :" << std::endl;
Span sp(5);
sp.addNumber(6);
sp.addNumber(3);
sp.addNumber(17);
sp.addNumber(9);
sp.addNumber(11);
std::cout << "Shortest span : " << sp.shortestSpan() << std::endl;
std::cout << "Longest span : " << sp.longestSpan() << std::endl;
std::cout << "\nTest exception (1 seul element) :" << std::endl;
try
{
Span small(1);
small.addNumber(42);
small.shortestSpan();
}
catch (const std::exception &e)
{
std::cout << "Exception attrapee : " << e.what() << std::endl;
}
std::cout << "\nTest 10000 elements :" << std::endl;
try
{
Span big(10000);
std::vector<int> v;
for (int i = 0; i < 10000; i++)
v.push_back(i);
std::cout << "Ajout de 10000 elements avec addRange :" << std::endl;
big.addRange(v.begin(), v.end());
std::cout << "Shortest span : " << big.shortestSpan() << std::endl;
std::cout << "Longest span : " << big.longestSpan() << std::endl;
}
catch (const std::exception &e)
{
std::cout << "Exception attrapee : " << e.what() << std::endl;
}
std::cout << "\nTest depassement de capacite :" << std::endl;
try
{
Span tiny(2);
tiny.addNumber(1);
tiny.addNumber(2);
tiny.addNumber(3);
}
catch (const std::exception &e)
{
std::cout << "Exception attrapee : " << e.what() << std::endl;
}
return 0;
}