GCC Code Coverage Report


Directory: ./
File: TESTS/TEST_WRITE_PNG/main.cpp
Date: 2025-09-08 17:09:06
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 2 2 100.0%
Branches: 13 13 100.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "PImagePng.h"
8
9 ///Test the write of a png file
10 /** @return true on success, false otherwise
11 */
12 1 bool testWritePng(){
13
2/2
✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
1 PPath fileName("output.png");
14 1 bool b(true);
15 1 size_t width(640lu), height(480lu);
16
1/1
✓ Branch 0 (5→6) taken 1 times.
1 PImagePng image;
17
1/1
✓ Branch 0 (6→7) taken 1 times.
1 b &= image.createImage(width, height);
18
1/1
✓ Branch 0 (7→8) taken 1 times.
1 NbColorByte nbBytePerPixel = image.getNbBytePerPixel();
19
1/1
✓ Branch 0 (8→9) taken 1 times.
1 png_bytep data = image.getData();
20
2/2
✓ Branch 0 (17→10) taken 640 times.
✓ Branch 1 (17→18) taken 1 times.
641 for(size_t i(0lu); i < width; ++i){
21
2/2
✓ Branch 0 (15→11) taken 307200 times.
✓ Branch 1 (15→16) taken 640 times.
307840 for(size_t j(0lu); j < height; ++j){
22
2/2
✓ Branch 0 (13→12) taken 921600 times.
✓ Branch 1 (13→14) taken 307200 times.
1228800 for(size_t k(0u); k < nbBytePerPixel; ++k){
23 921600 size_t index((i*height + j)*nbBytePerPixel + k);
24 921600 data[index] = (index*257lu)%255lu;
25 }
26 }
27 }
28
1/1
✓ Branch 0 (18→19) taken 1 times.
1 b &= image.write(fileName);
29 1 return b;
30 1 }
31
32 1 int main(int argc, char** argv){
33 1 bool b(true);
34 1 b &= testWritePng();
35 1 return b - 1;
36 }
37
38