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

saitoha / libsixel / 21335896708

25 Jan 2026 04:33PM UTC coverage: 76.581% (-2.3%) from 78.904%
21335896708

push

github

saitoha
meson: set build type to plain

20012 of 44638 branches covered (44.83%)

36354 of 47471 relevant lines covered (76.58%)

13461842.27 hits per line

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

78.26
/tests/filter/0010_filter_encode.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
#include <stdlib.h>
14

15
#include <sixel.h>
16

17
#include "src/filter-encode.h"
18
#include "src/filter-factory.h"
19
#include "src/filter.h"
20
#include "tests/filter/filter_test_common.h"
21
#include "src/output.h"
22

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

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

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

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

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

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

73
    config.dither = dither;
13✔
74
    config.output = output;
13✔
75
    config.output_colorspace = expected_colorspace;
13✔
76

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

84
    sixel_filter_bind_input(filter,
16✔
85
                            &frame,
86
                            frame->pixelformat,
7✔
87
                            frame->colorspace);
13✔
88
    sixel_filter_set_progress(filter, progress_cb, &progress, 1);
13✔
89

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

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

100
    if (output->colorspace != expected_colorspace) {
13!
101
        status = SIXEL_BAD_ARGUMENT;
×
102
        goto cleanup;
×
103
    }
104

105
    if (output->source_colorspace != frame->colorspace) {
13!
106
        status = SIXEL_BAD_ARGUMENT;
×
107
        goto cleanup;
×
108
    }
109

110
    if (dither->pixelformat != frame->pixelformat) {
13!
111
        status = SIXEL_BAD_ARGUMENT;
×
112
        goto cleanup;
×
113
    }
114

115
    if (counter.calls <= 0 || counter.bytes <= 0) {
13!
116
        status = SIXEL_BAD_ARGUMENT;
×
117
        goto cleanup;
×
118
    }
119

120
    if (progress.began != 1 || progress.completed != 1 || progress.aborted) {
13!
121
        status = SIXEL_BAD_ARGUMENT;
×
122
        goto cleanup;
×
123
    }
124

125
cleanup:
10✔
126
    sixel_filter_teardown(filter);
13✔
127
    sixel_filter_free(filter);
13✔
128
    if (output != NULL) {
13!
129
        sixel_output_unref(output);
13✔
130
    }
3✔
131
    if (dither != NULL) {
13!
132
        sixel_dither_unref(dither);
13✔
133
    }
3✔
134
    sixel_frame_unref(frame);
13✔
135
    sixel_allocator_unref(allocator);
13✔
136

137
    return SIXEL_SUCCEEDED(status);
14✔
138
}
1✔
139

140
int
141
test_filter_0010_filter_encode(int argc, char **argv)
13✔
142
{
143
    int success;
7✔
144

145
    (void) argc;
9✔
146
    (void) argv;
9✔
147

148
    success = 1;
13✔
149

150
    if (!test_encode_updates_output_and_progress()) {
13!
151
        fprintf(stderr,
×
152
                "encode filter writes metadata and streams data failed\n");
153
        success = 0;
×
154
    }
155

156
    return success ? EXIT_SUCCESS : EXIT_FAILURE;
14✔
157
}
1✔
158

159
/* emacs Local Variables:      */
160
/* emacs mode: c               */
161
/* emacs tab-width: 4          */
162
/* emacs indent-tabs-mode: nil */
163
/* emacs c-basic-offset: 4     */
164
/* emacs End:                  */
165
/* vim: set expandtab ts=4 sts=4 sw=4 : */
166
/* 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