[FFmpeg-devel] [PATCH] remove unused and broken test program in libavutil/base64.c
Stefano Sabatini
stefano.sabatini-lala
Fri Feb 6 01:30:51 CET 2009
On date Friday 2009-02-06 01:05:33 +0100, Michael Niedermayer encoded:
> On Thu, Feb 05, 2009 at 11:19:41PM +0100, Stefano Sabatini wrote:
> > On date Thursday 2009-02-05 21:35:25 +0100, Michael Niedermayer encoded:
> > [...]
> > > considering our agreement on the irrelevnace of the code
> > > please remove the tests for invalidness, remove the hex dumping and
> > > try to remove as much of the other code as well.
> > > also either the fixed vectors or the random ones must be dropped
> > > they are redundant in some sense (keep whats less code)
> > >
> > > its just a simple self test, what you wrote is overkill IMHO
> >
> > New round, regards.
> > --
> > FFmpeg = Friendly & Free Mythic Picky Encoding/decoding Guru
>
> > Index: ffmpeg/libavutil/base64.c
> > ===================================================================
> > --- ffmpeg.orig/libavutil/base64.c 2009-02-01 18:56:01.000000000 +0100
> > +++ ffmpeg/libavutil/base64.c 2009-02-05 23:17:00.000000000 +0100
> > @@ -98,3 +98,69 @@
> >
> > return ret;
> > }
> > +
> > +#ifdef TEST
> > +
> > +#undef printf
> > +
> > +#define MAX_DATA_SIZE 1024
> > +#define MAX_ENCODED_SIZE 2048
> > +
> > +int test_encode_decode(const uint8_t *data, unsigned int data_size, const char *encoded_ref)
> > +{
> > + char encoded[MAX_ENCODED_SIZE];
> > + uint8_t data2[MAX_DATA_SIZE];
> > + int data2_size, max_data2_size = MAX_DATA_SIZE;
> > +
> > + if (!av_base64_encode(encoded, MAX_ENCODED_SIZE, data, data_size)) {
> > + printf("Failed: cannot encode the input data\n");
> > + return 1;
> > + }
>
> > + if (encoded_ref && strcmp(encoded, encoded_ref)) {
> > + printf("Failed: encoded string differs from reference\n");
> > + printf("Encoded:\n%s\n", encoded);
> > + printf("Reference:\n%s\n", encoded_ref);
> > + return 1;
> > + }
> > +
> > + if ((data2_size = av_base64_decode(data2, encoded, max_data2_size)) < 0) {
> > + printf("Failed: cannot decode the encoded string\n");
> > + printf("Encoded:\n%s\n", encoded);
> > + return 1;
> > + }
>
> mergeable printf()
>
>
> > + if (memcmp(data2, data, data_size)) {
> > + printf("Failed: encoded/decoded data differs from original data\n");
> > + return 1;
> > + }
> > +
> > + printf("Passed!\n");
> > + return 0;
> > +}
> > +
> > +int main(void)
> > +{
> > + int error_count = 0;
> > + struct test {
> > + const uint8_t *data;
> > + int data_size;
> > + const char *encoded_ref;
> > + } tests[] = {
> > + { "", 0, ""},
> > + { "1", 1, "MQ=="},
> > + { "22", 2, "MjI="},
> > + { "333", 3, "MzMz"},
> > + { "4444", 4, "NDQ0NA=="},
> > + { "55555", 5, "NTU1NTU="},
> > + { "666666", 6, "NjY2NjY2"},
> > + { "abc:def", 7, "YWJjOmRlZg=="},
> > + };
>
> data_size is redundant
>
>
> > +
> > + printf("Encoding/decoding tests\n");
> > +
>
> > + for (int i = 0 [...]
>
> gcc 2.95 dislikes this
> also i think our coding rules say that C99 features that arent used
> in ffmpeg yet shouldnt be added lightly
New round, regards.
--
FFmpeg = Foolish and Faboulous Mind-dumbing Picky EntanGlement
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-new-base64-test.patch
Type: text/x-diff
Size: 2049 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090206/591fe887/attachment.patch>
More information about the ffmpeg-devel
mailing list