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 | ///Check the const image | ||
10 | /** @param image : image to be checked | ||
11 | * @return true on success, false otherwise | ||
12 | */ | ||
13 | 1 | bool checkConstImage(const PImagePng & image){ | |
14 | 1 | const png_byte* ptr = image.getData(); | |
15 | 1 | return ptr != NULL; | |
16 | } | ||
17 | |||
18 | ///Test the read of a png file | ||
19 | /** @return true on success, false otherwise | ||
20 | */ | ||
21 | 1 | bool testReadPng(){ | |
22 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | PPath fileName(LOGO_PNG_IMAGE); |
23 | |||
24 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | PImagePng image; |
25 | 1 | bool b(true); | |
26 |
3/3✓ Branch 0 (6→7) taken 1 times.
✓ Branch 2 (7→8) taken 1 times.
✓ Branch 4 (8→9) taken 1 times.
|
1 | b &= !image.read(PPath("")); |
27 |
3/3✓ Branch 0 (11→12) taken 1 times.
✓ Branch 2 (12→13) taken 1 times.
✓ Branch 4 (13→14) taken 1 times.
|
1 | b &= !image.read(PPath("someInexistingFile.png")); |
28 |
3/3✓ Branch 0 (16→17) taken 1 times.
✓ Branch 2 (17→18) taken 1 times.
✓ Branch 4 (18→19) taken 1 times.
|
1 | b &= !image.read(PPath("someInexistingFile.txt")); |
29 |
1/1✓ Branch 0 (21→22) taken 1 times.
|
1 | b &= image.read(fileName); |
30 | |||
31 |
10/10✓ Branch 0 (22→23) taken 1 times.
✓ Branch 2 (23→24) taken 1 times.
✓ Branch 4 (24→25) taken 1 times.
✓ Branch 6 (25→26) taken 1 times.
✓ Branch 8 (26→27) taken 1 times.
✓ Branch 10 (27→28) taken 1 times.
✓ Branch 12 (28→29) taken 1 times.
✓ Branch 14 (29→30) taken 1 times.
✓ Branch 16 (30→31) taken 1 times.
✓ Branch 18 (31→32) taken 1 times.
|
1 | std::cout << "testReadPng : image width = " << image.getWidth() << ", height = " << image.getHeight() << ", nbBytePerPixel = " << image.getNbBytePerPixel() << std::endl; |
32 | |||
33 |
1/1✓ Branch 0 (32→33) taken 1 times.
|
1 | b &= image.getWidth() == 346u; |
34 |
1/1✓ Branch 0 (33→34) taken 1 times.
|
1 | b &= image.getHeight() == 70u; |
35 |
1/1✓ Branch 0 (34→35) taken 1 times.
|
1 | b &= image.getNbBytePerPixel() == 4; |
36 |
3/3✓ Branch 0 (35→36) taken 1 times.
✓ Branch 2 (36→37) taken 1 times.
✓ Branch 4 (37→38) taken 1 times.
|
1 | std::cout << "testReadPng : after read b = " << b << std::endl; |
37 |
2/2✓ Branch 0 (38→39) taken 1 times.
✓ Branch 2 (39→40) taken 1 times.
|
1 | PImagePng image2(image), image3; |
38 |
1/1✓ Branch 0 (40→41) taken 1 times.
|
1 | image3 = image; |
39 | |||
40 |
2/2✓ Branch 0 (41→42) taken 1 times.
✓ Branch 2 (42→43) taken 1 times.
|
1 | b &= image2.getWidth() == image.getWidth(); |
41 |
2/2✓ Branch 0 (43→44) taken 1 times.
✓ Branch 2 (44→45) taken 1 times.
|
1 | b &= image3.getWidth() == image.getWidth(); |
42 |
3/3✓ Branch 0 (45→46) taken 1 times.
✓ Branch 2 (46→47) taken 1 times.
✓ Branch 4 (47→48) taken 1 times.
|
1 | std::cout << "testReadPng : copy image width : b = " << b << std::endl; |
43 |
2/2✓ Branch 0 (48→49) taken 1 times.
✓ Branch 2 (49→50) taken 1 times.
|
1 | b &= image2.getHeight() == image.getHeight(); |
44 |
2/2✓ Branch 0 (50→51) taken 1 times.
✓ Branch 2 (51→52) taken 1 times.
|
1 | b &= image3.getHeight() == image.getHeight(); |
45 |
3/3✓ Branch 0 (52→53) taken 1 times.
✓ Branch 2 (53→54) taken 1 times.
✓ Branch 4 (54→55) taken 1 times.
|
1 | std::cout << "testReadPng : copy image height : b = " << b << std::endl; |
46 |
2/2✓ Branch 0 (55→56) taken 1 times.
✓ Branch 2 (56→57) taken 1 times.
|
1 | b &= image2.getNbBytePerPixel() == image.getNbBytePerPixel(); |
47 |
2/2✓ Branch 0 (57→58) taken 1 times.
✓ Branch 2 (58→59) taken 1 times.
|
1 | b &= image3.getNbBytePerPixel() == image.getNbBytePerPixel(); |
48 |
3/3✓ Branch 0 (59→60) taken 1 times.
✓ Branch 2 (60→61) taken 1 times.
✓ Branch 4 (61→62) taken 1 times.
|
1 | std::cout << "testReadPng : copy image nbBytePerPixel : b = " << b << std::endl; |
49 |
1/1✓ Branch 0 (62→63) taken 1 times.
|
1 | image3.createImage(200, 100); |
50 | 1 | color_t r(0), g(0), b1(0), a(0), r3(0), g3(0), b3(0), a3(0); | |
51 |
1/1✓ Branch 0 (63→64) taken 1 times.
|
1 | image.getColor(20lu, 10lu, r, g, b1, a); |
52 |
1/1✓ Branch 0 (64→65) taken 1 times.
|
1 | image2.getColor(20lu, 10lu, r3, g3, b3, a3); |
53 | 1 | b &= r == r3; | |
54 |
3/3✓ Branch 0 (65→66) taken 1 times.
✓ Branch 2 (66→67) taken 1 times.
✓ Branch 4 (67→68) taken 1 times.
|
1 | std::cout << "testReadPng : check R b = " << b << std::endl; |
55 | 1 | b &= g == g3; | |
56 |
3/3✓ Branch 0 (68→69) taken 1 times.
✓ Branch 2 (69→70) taken 1 times.
✓ Branch 4 (70→71) taken 1 times.
|
1 | std::cout << "testReadPng : check G b = " << b << std::endl; |
57 | 1 | b &= b1 == b3; | |
58 |
3/3✓ Branch 0 (71→72) taken 1 times.
✓ Branch 2 (72→73) taken 1 times.
✓ Branch 4 (73→74) taken 1 times.
|
1 | std::cout << "testReadPng : check B b = " << b << std::endl; |
59 | 1 | b &= a == a3; | |
60 |
3/3✓ Branch 0 (74→75) taken 1 times.
✓ Branch 2 (75→76) taken 1 times.
✓ Branch 4 (76→77) taken 1 times.
|
1 | std::cout << "testReadPng : check A b = " << b << std::endl; |
61 |
1/1✓ Branch 0 (77→78) taken 1 times.
|
1 | b &= checkConstImage(image); |
62 |
3/3✓ Branch 0 (78→79) taken 1 times.
✓ Branch 2 (79→80) taken 1 times.
✓ Branch 4 (80→81) taken 1 times.
|
1 | std::cout << "testReadPng : b = " << b << std::endl; |
63 | 1 | return b; | |
64 | 1 | } | |
65 | |||
66 | ///Test the basic image | ||
67 | /** @return true on success, false otherwise | ||
68 | */ | ||
69 | 1 | bool testBasePImage(){ | |
70 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PImagePng image; |
71 | |||
72 | 1 | bool b(true); | |
73 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | b &= image.getWidth() == 0lu; |
74 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | b &= image.getHeight() == 0u; |
75 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | b &= image.getNbBytePerPixel() == 0; |
76 | |||
77 | 1 | return b; | |
78 | 1 | } | |
79 | |||
80 | 1 | int main(int argc, char** argv){ | |
81 | 1 | bool b(true); | |
82 | 1 | b &= testReadPng(); | |
83 | 1 | b &= testBasePImage(); | |
84 | 1 | return b - 1; | |
85 | } | ||
86 | |||
87 |