d07 ex02 ok avec test main de l'enoncé
This commit is contained in:
BIN
d07/ex02/array
BIN
d07/ex02/array
Binary file not shown.
@@ -146,36 +146,49 @@ int main() {
|
|||||||
#define MAX_VAL 750
|
#define MAX_VAL 750
|
||||||
Array<int> numbers(MAX_VAL);
|
Array<int> numbers(MAX_VAL);
|
||||||
int* mirror = new int[MAX_VAL];
|
int* mirror = new int[MAX_VAL];
|
||||||
for (int i = 0; i < MAX_VAL; i++) {
|
srand(time(NULL));
|
||||||
const int value = rand();
|
for (int i = 0; i < MAX_VAL; i++)
|
||||||
numbers[i] = value;
|
{
|
||||||
mirror[i] = value;
|
const int value = rand();
|
||||||
|
numbers[i] = value;
|
||||||
|
mirror[i] = value;
|
||||||
}
|
}
|
||||||
//SCOPE
|
//SCOPE
|
||||||
{
|
{
|
||||||
Array<int> tmp = numbers;
|
Array<int> tmp = numbers;
|
||||||
Array<int> test(tmp);
|
Array<int> test(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_VAL; i++) {
|
for (int i = 0; i < MAX_VAL; i++)
|
||||||
if (mirror[i] != numbers[i]) {
|
{
|
||||||
std::cerr << "didn't save the same value!!" << '\n';
|
if (mirror[i] != numbers[i])
|
||||||
return 1;
|
{
|
||||||
}
|
std::cerr << "didn't save the same value!!" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try
|
||||||
numbers[-2] = 0;}
|
{
|
||||||
catch(const std::exception& e) {
|
numbers[-2] = 0;
|
||||||
std::cerr << e.what() << '\n';}
|
|
||||||
try {
|
|
||||||
numbers[MAX_VAL] = 0;}
|
|
||||||
catch(const std::exception& e) {
|
|
||||||
std::cerr << e.what() << '\n';}
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_VAL; i++) {
|
|
||||||
numbers[i] = rand();
|
|
||||||
}
|
}
|
||||||
delete [] mirror;
|
catch(const std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
numbers[MAX_VAL] = 0;
|
||||||
|
}
|
||||||
|
catch(const std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_VAL; i++)
|
||||||
|
{
|
||||||
|
numbers[i] = rand();
|
||||||
|
}
|
||||||
|
delete [] mirror;//
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
53
d07/main.cpp
53
d07/main.cpp
@@ -1,53 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <Array.hpp>
|
|
||||||
|
|
||||||
#define MAX_VAL 750
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
Array<int> numbers(MAX_VAL);
|
|
||||||
int* mirror = new int[MAX_VAL];
|
|
||||||
srand(time(NULL));
|
|
||||||
for (int i = 0; i < MAX_VAL; i++)
|
|
||||||
{
|
|
||||||
const int value = rand();
|
|
||||||
numbers[i] = value;
|
|
||||||
mirror[i] = value;
|
|
||||||
}
|
|
||||||
//SCOPE
|
|
||||||
{
|
|
||||||
Array<int> tmp = numbers;
|
|
||||||
Array<int> test(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_VAL; i++)
|
|
||||||
{
|
|
||||||
if (mirror[i] != numbers[i])
|
|
||||||
{
|
|
||||||
std::cerr << "didn't save the same value!!" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
numbers[-2] = 0;
|
|
||||||
}
|
|
||||||
catch(const std::exception& e)
|
|
||||||
{
|
|
||||||
std::cerr << e.what() << '\n';
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
numbers[MAX_VAL] = 0;
|
|
||||||
}
|
|
||||||
catch(const std::exception& e)
|
|
||||||
{
|
|
||||||
std::cerr << e.what() << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_VAL; i++)
|
|
||||||
{
|
|
||||||
numbers[i] = rand();
|
|
||||||
}
|
|
||||||
delete [] mirror;//
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user