• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

saitoha / libsixel / 20564600453

29 Dec 2025 03:58AM UTC coverage: 57.322% (-0.6%) from 57.909%
20564600453

push

github

saitoha
Merge branch 'tests/add_missing_tests' into develop

14331 of 44427 branches covered (32.26%)

4 of 9 new or added lines in 2 files covered. (44.44%)

3037 existing lines in 16 files now uncovered.

25159 of 43891 relevant lines covered (57.32%)

4506872.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.82
/tests/filter/filter_encode_tests.c
1
/*
2
 * SPDX-License-Identifier: MIT
3
 *
4
 * Encode filter tests. These verify that the filter sets output metadata,
5
 * forwards pixels to the encoder, and reports progress via callbacks.
6
 */
7

8
#if defined(HAVE_CONFIG_H)
9
#include "config.h"
10
#endif
11

12
#include <stdio.h>
13

14
#include <sixel.h>
15

16
#include "filter-encode.h"
17
#include "filter-factory.h"
18
#include "filter.h"
19
#include "filter_test_common.h"
20
#include "output.h"
21

22
static int
23
test_encode_updates_output_and_progress(void)
5✔
24
{
25
    SIXELSTATUS status;
5✔
26
    sixel_allocator_t *allocator;
5✔
27
    sixel_filter_t *filter;
5✔
28
    sixel_filter_encode_config_t config;
5✔
29
    sixel_frame_t *frame;
5✔
30
    sixel_dither_t *dither;
5✔
31
    sixel_output_t *output;
5✔
32
    test_progress_t progress;
5✔
33
    test_output_counter_t counter;
5✔
34
    int expected_pixelformat;
5✔
35
    int expected_colorspace;
5✔
36

37
    status = SIXEL_FALSE;
5✔
38
    allocator = NULL;
5✔
39
    filter = NULL;
5✔
40
    frame = NULL;
5✔
41
    dither = NULL;
5✔
42
    output = NULL;
5✔
43
    progress.began = 0;
5✔
44
    progress.progressed = 0;
5✔
45
    progress.completed = 0;
5✔
46
    progress.aborted = 0;
5✔
47
    counter.calls = 0;
5✔
48
    counter.bytes = 0;
5✔
49
    expected_pixelformat = SIXEL_PIXELFORMAT_RGB888;
5✔
50
    expected_colorspace = SIXEL_COLORSPACE_LINEAR;
5✔
51

52
    status = make_allocator(&allocator);
5✔
53
    if (SIXEL_FAILED(status)) {
5!
54
        goto cleanup;
×
55
    }
56

57
    status = make_rgb_frame(allocator, 2, 2, &frame);
5✔
58
    if (SIXEL_FAILED(status)) {
5!
59
        goto cleanup;
×
60
    }
61

62
    expected_colorspace = sixel_frame_get_colorspace(frame);
5✔
63

64
    status = make_dither(allocator, 8, &dither);
5✔
65
    if (SIXEL_FAILED(status)) {
5!
UNCOV
66
        goto cleanup;
×
67
    }
68

69
    status = make_counter_output(allocator, &counter, &output);
5✔
70
    if (SIXEL_FAILED(status)) {
5!
UNCOV
71
        goto cleanup;
×
72
    }
73

74
    config.dither = dither;
5✔
75
    config.output = output;
5✔
76
    config.output_colorspace = expected_colorspace;
5✔
77

78
    status = sixel_filter_factory_create_by_kind(SIXEL_FILTER_KIND_ENCODE,
5✔
79
                                                 &config,
80
                                                 &filter);
81
    if (SIXEL_FAILED(status)) {
5!
UNCOV
82
        goto cleanup;
×
83
    }
84

85
    sixel_filter_bind_input(filter,
5✔
86
                            &frame,
87
                            frame->pixelformat,
5✔
88
                            sixel_frame_get_colorspace(frame));
89
    sixel_filter_set_progress(filter, progress_cb, &progress, 1);
5✔
90

91
    status = sixel_filter_run(filter, allocator, NULL);
5✔
92
    if (SIXEL_FAILED(status)) {
5!
UNCOV
93
        goto cleanup;
×
94
    }
95

96
    if (output->pixelformat != expected_pixelformat) {
5!
UNCOV
97
        status = SIXEL_BAD_ARGUMENT;
×
UNCOV
98
        goto cleanup;
×
99
    }
100

101
    if (sixel_pixelformat_colorspace_from_format(output->pixelformat)
5!
102
            != expected_colorspace) {
UNCOV
103
        status = SIXEL_BAD_ARGUMENT;
×
UNCOV
104
        goto cleanup;
×
105
    }
106

107
    if (dither->pixelformat != frame->pixelformat) {
5!
UNCOV
108
        status = SIXEL_BAD_ARGUMENT;
×
UNCOV
109
        goto cleanup;
×
110
    }
111

112
    if (counter.calls <= 0 || counter.bytes <= 0) {
5!
UNCOV
113
        status = SIXEL_BAD_ARGUMENT;
×
UNCOV
114
        goto cleanup;
×
115
    }
116

117
    if (progress.began != 1 || progress.completed != 1 || progress.aborted) {
5!
UNCOV
118
        status = SIXEL_BAD_ARGUMENT;
×
UNCOV
119
        goto cleanup;
×
120
    }
121

122
cleanup:
5✔
123
    sixel_filter_teardown(filter);
5✔
124
    sixel_filter_free(filter);
5✔
125
    if (output != NULL) {
5!
126
        sixel_output_unref(output);
5✔
127
    }
128
    if (dither != NULL) {
5!
129
        sixel_dither_unref(dither);
5✔
130
    }
131
    sixel_frame_unref(frame);
5✔
132
    sixel_allocator_unref(allocator);
5✔
133

134
    return SIXEL_SUCCEEDED(status);
5✔
135
}
136

137
int main(void)
5✔
138
{
139
    int success;
5✔
140

141
    success = 1;
5✔
142
    printf("1..1\n");
5✔
143

144
    if (test_encode_updates_output_and_progress()) {
5!
145
        printf("ok 1 - encode filter writes metadata and streams data\n");
5✔
146
    } else {
UNCOV
147
        printf("not ok 1 - encode filter writes metadata and streams data\n");
×
UNCOV
148
        success = 0;
×
149
    }
150

151
    return success ? 0 : 1;
5✔
152
}
153

154
/* emacs Local Variables:      */
155
/* emacs mode: c               */
156
/* emacs tab-width: 4          */
157
/* emacs indent-tabs-mode: nil */
158
/* emacs c-basic-offset: 4     */
159
/* emacs End:                  */
160
/* vim: set expandtab ts=4 sts=4 sw=4 : */
161
/* EOF */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc