FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/tests/id3v2enc.c
Date: 2026-10-11 08:45:34
Exec Total Coverage
Lines: 15 18 83.3%
Functions: 1 1 100.0%
Branches: 8 10 80.0%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <stdio.h>
20
21 #include "libavutil/mem.h"
22 #include "libavformat/avio.h"
23 #include "libavformat/id3v2.h"
24
25 1 int main(void)
26 {
27
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (int version = 3; version <= 4; version++) {
28 2 ID3v2EncContext id3 = { 0 };
29
30
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for (int tag = 0; tag < 3; tag++) {
31 AVIOContext *pb;
32 uint8_t *buf;
33 int initial_len, size;
34
35 /* Test zeroed, reused, and explicitly nonzero contexts. */
36
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (tag == 2)
37 2 id3.len = 123;
38
39
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (avio_open_dyn_buf(&pb) < 0)
40 ✗ return 1;
41
42 6 ff_id3v2_start(&id3, pb, version, ID3v2_DEFAULT_MAGIC);
43 6 initial_len = id3.len;
44 6 ff_id3v2_finish(&id3, pb, 10);
45 6 size = avio_close_dyn_buf(pb, &buf);
46
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (size < ID3v2_HEADER_SIZE) {
47 ✗ av_free(buf);
48 ✗ return 1;
49 }
50 6 printf("version=%d tag=%d initial_len=%d declared=%d actual=%d\n",
51 version, tag, initial_len, ff_id3v2_tag_len(buf), size);
52 6 av_free(buf);
53 }
54 }
55 1 return 0;
56 }
57