Skip to content
Snippets Groups Projects
Commit 5da13a9d authored by Jean-Marc's avatar Jean-Marc
Browse files

test modifs

parent cab0a0e4
No related branches found
No related tags found
No related merge requests found
Pipeline #190232 failed
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -7,10 +7,11 @@ using namespace std;
Image::Image()
{
tab = nullptr;
cout<<"tab cons : "<<tab<<endl;
tab = new Pixel [1];
cout<<"tab alloué : "<<tab<<endl;
dimx = 0;
dimy = 0;
}
Image::Image(const unsigned int &x, const unsigned int &y)
......@@ -20,7 +21,7 @@ Image::Image(const unsigned int &x, const unsigned int &y)
dimx = x;
dimy = y;
tab = new Pixel [dimx*dimy];
cout<<"tab cons2 : "<<tab<<endl;
cout<<"tab alloué v2 : "<<tab<<endl;
}
Image::~Image()
......@@ -29,7 +30,7 @@ Image::~Image()
dimy = 0;
tab = nullptr;
delete [] tab;
cout<<"tab dest : "<<tab<<endl;
cout<<"tab détruit : "<<tab<<endl;
}
......
#ifndef _IMAGE_H
#define _IMAGE_H
#include "Pixel.h"
#include <cassert>
#include <iostream>
using namespace std;
......@@ -18,6 +19,39 @@ private:
~Image();
void static testRegression()
{
Image im1;
Image im2(50,50);
Pixel p;
assert(im1.dimx == 0);
assert(im1.dimy == 0);
p = im2.getPix(10,15);
assert(p.r == 0);
assert(p.g == 0);
assert(p.b == 0);
p = im2.getPix2(18,36);
assert(p.r == 0);
assert(p.g == 0);
assert(p.b == 0);
Pixel p2(140,169,78);
//cout<<int(p2.r)<<" "<<int(p2.g)<<endl;
im1.dimx = 50;
im1.dimy = 50;
im1.setPix(25,14,p2);
Pixel p3 = im1.getPix2(25,14);
//cout<<int(p3.r)<<" "<<int(p3.g)<<endl;
assert(p3.r == 140);
assert(p3.g == 169);
assert(p3.b == 78);
im2.dessinerRectangle(10,10,20,20,p2);
im2.effacer(p3);
//cout<<im2.getPix(25,14).r<<" "<<im2.getPix(25,14).g<<endl;
assert(im2.getPix(25,14).r == 140);
assert(im2.getPix(25,14).g == 169);
assert(im2.getPix(25,14).b == 78);
}
Pixel & getPix(const unsigned int &x, const unsigned int &y) const;
......
......@@ -6,6 +6,5 @@ using namespace std;
int main (void)
{
Image::testRegression();
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment