forked from xiaozhuai/imageinfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_files.cpp
131 lines (109 loc) · 6.77 KB
/
test_files.cpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// Created by xiaozhuai on 2021/4/1.
//
#include <cstdio>
#include "imageinfo.hpp"
#define ASSET_II(file, error, format, width, height) do { \
auto imageInfo = getImageInfo<IIFilePathReader>(file); \
if (imageInfo.getErrorCode() != (error)) { \
fprintf(stderr, "Error ASSET_II, file: %s, line: %d, error != %s\n", file, __LINE__, #error); \
exit(1); \
} \
else if (imageInfo.getFormat() != (format)) { \
fprintf(stderr, "Error ASSET_II, file: %s, line: %d, format != %s\n", file, __LINE__, #format); \
exit(1); \
} \
else if (imageInfo.getWidth() != (width)) { \
fprintf(stderr, "Error ASSET_II, file: %s, line: %d, width != %ld\n", file, __LINE__, (width)); \
exit(1); \
} \
else if (imageInfo.getHeight() != (height)) { \
fprintf(stderr, "Error ASSET_II, file: %s, line: %d, height != %ld\n", file, __LINE__, (height)); \
exit(1); \
} \
else { \
printf("Test passed, file: %s \n", file); \
} \
} while(0)
int main() {
{
ASSET_II(IMAGES_DIRECTORY "valid/avif/sample.avif", II_ERR_OK, II_FORMAT_AVIF, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/avif/sample2.avif", II_ERR_OK, II_FORMAT_AVIF, 800l, 533l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/bmp/sample.bmp", II_ERR_OK, II_FORMAT_BMP, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/bmp/sample2.bmp", II_ERR_OK, II_FORMAT_BMP, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/cur/sample.cur", II_ERR_OK, II_FORMAT_CUR, 32l, 32l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/dds/sample.dds", II_ERR_OK, II_FORMAT_DDS, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/gif/sample.gif", II_ERR_OK, II_FORMAT_GIF, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/hdr/sample.hdr", II_ERR_OK, II_FORMAT_HDR, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/heic/sample.heic", II_ERR_OK, II_FORMAT_HEIC, 122l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/heic/sample2.heic", II_ERR_OK, II_FORMAT_HEIC, 1440l, 960l);
ASSET_II(IMAGES_DIRECTORY "valid/heic/sample3.heic", II_ERR_OK, II_FORMAT_HEIC, 1280l, 854l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/icns/sample.icns", II_ERR_OK, II_FORMAT_ICNS, 128l, 128l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/ico/multi-size.ico", II_ERR_OK, II_FORMAT_ICO, 256l, 256l);
ASSET_II(IMAGES_DIRECTORY "valid/ico/multi-size-compressed.ico", II_ERR_OK, II_FORMAT_ICO, 256l, 256l);
ASSET_II(IMAGES_DIRECTORY "valid/ico/sample.ico", II_ERR_OK, II_FORMAT_ICO, 32l, 32l);
ASSET_II(IMAGES_DIRECTORY "valid/ico/sample-256.ico", II_ERR_OK, II_FORMAT_ICO, 256l, 256l);
ASSET_II(IMAGES_DIRECTORY "valid/ico/sample-256-compressed.ico", II_ERR_OK, II_FORMAT_ICO, 256l, 256l);
ASSET_II(IMAGES_DIRECTORY "valid/ico/sample-compressed.ico", II_ERR_OK, II_FORMAT_ICO, 32l, 32l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/jp2/sample.jp2", II_ERR_OK, II_FORMAT_JP2, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/jp2/jpx_disguised_as_jp2.jp2", II_ERR_OK, II_FORMAT_JP2, 2717l, 3701l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/jpg/1x2-flipped-big-endian.jpg", II_ERR_OK, II_FORMAT_JPEG, 1l, 2l);
ASSET_II(IMAGES_DIRECTORY "valid/jpg/1x2-flipped-little-endian.jpg", II_ERR_OK, II_FORMAT_JPEG, 1l, 2l);
ASSET_II(IMAGES_DIRECTORY "valid/jpg/large.jpg", II_ERR_OK, II_FORMAT_JPEG, 1600l, 1200l);
ASSET_II(IMAGES_DIRECTORY "valid/jpg/optimized.jpg", II_ERR_OK, II_FORMAT_JPEG, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/jpg/progressive.jpg", II_ERR_OK, II_FORMAT_JPEG, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/jpg/sample.jpg", II_ERR_OK, II_FORMAT_JPEG, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/jpg/sampleExported.jpg", II_ERR_OK, II_FORMAT_JPEG, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/jpg/very-large.jpg", II_ERR_OK, II_FORMAT_JPEG, 4800l, 3600l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/jpx/sample.jpx", II_ERR_OK, II_FORMAT_JPX, 2717l, 3701l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/ktx/sample.ktx", II_ERR_OK, II_FORMAT_KTX, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/png/sample.png", II_ERR_OK, II_FORMAT_PNG, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/png/sample_fried.png", II_ERR_OK, II_FORMAT_PNG, 128l, 68l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/psd/sample.psd", II_ERR_OK, II_FORMAT_PSD, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/tga/sample.tga", II_ERR_OK, II_FORMAT_TGA, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/tiff/big-endian.tiff", II_ERR_OK, II_FORMAT_TIFF, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/tiff/jpeg.tiff", II_ERR_OK, II_FORMAT_TIFF, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/tiff/little-endian.tiff", II_ERR_OK, II_FORMAT_TIFF, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "valid/webp/lossless.webp", II_ERR_OK, II_FORMAT_WEBP, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/webp/extended.webp", II_ERR_OK, II_FORMAT_WEBP, 123l, 456l);
ASSET_II(IMAGES_DIRECTORY "valid/webp/lossy.webp", II_ERR_OK, II_FORMAT_WEBP, 123l, 456l);
}
{
ASSET_II(IMAGES_DIRECTORY "invalid/sample.png", II_ERR_DECODE_SIZE_FAILED, II_FORMAT_PNG, -1l, -1l);
}
return 0;
}