[FFmpeg-cvslog] r17024 - trunk/libavutil/base64.c

stefano subversion
Sat Feb 7 00:24:17 CET 2009


Author: stefano
Date: Sat Feb  7 00:24:17 2009
New Revision: 17024

Log:
Remove broken test program.

Modified:
   trunk/libavutil/base64.c

Modified: trunk/libavutil/base64.c
==============================================================================
--- trunk/libavutil/base64.c	Fri Feb  6 21:42:21 2009	(r17023)
+++ trunk/libavutil/base64.c	Sat Feb  7 00:24:17 2009	(r17024)
@@ -98,129 +98,3 @@ char *av_base64_encode(char * buf, int b
 
     return ret;
 }
-
-#ifdef TEST
-#include "log.h"
-#include "mem.h"
-
-int main(void)
-{
-    int numerr = 0;
-    int len;
-    int numtest = 1;
-    uint8_t decode[1000];
-    struct test {
-        void *data;
-        int len;
-        const char *result;
-    } *t, tests[] = {
-        {
-        "", 0, ""}, {
-        "1", 1, "MQ=="}, {
-        "22", 2, "MjI="}, {
-        "333", 3, "MzMz"}, {
-        "4444", 4, "NDQ0NA=="}, {
-        "55555", 5, "NTU1NTU="}, {
-        "abc:def", 7, "YWJjOmRlZg=="}, {
-        NULL}
-    };
-    for (t = tests; t->data; t++) {
-        char *str;
-
-        av_log(NULL, AV_LOG_ERROR, "Encoding %s...\n", (char *) t->data);
-        str = av_base64_encode(t->data, t->len);
-        if (str) {
-            av_log(NULL, AV_LOG_ERROR, "Encoded to %s...\n", str);
-            if (strcmp(str, t->result) != 0) {
-                av_log(NULL, AV_LOG_ERROR, "failed test %d: %s != %s\n",
-                       numtest, str, t->result);
-                numerr++;
-            }
-            av_free(str);
-        }
-
-        av_log(NULL, AV_LOG_ERROR, "Done encoding, about to decode...\n");
-        len = av_base64_decode(decode, t->result, sizeof(decode));
-        if (len != t->len) {
-            av_log(NULL, AV_LOG_ERROR, "failed test %d: len %d != %d\n",
-                   numtest, len, t->len);
-            numerr++;
-        } else if (memcmp(decode, t->data, t->len) != 0) {
-            av_log(NULL, AV_LOG_ERROR, "failed test %d: data\n", numtest);
-            numerr++;
-        } else {
-            av_log(NULL, AV_LOG_ERROR, "Decoded to %s\n",
-                   (char *) t->data);
-        }
-        numtest++;
-    }
-
-#undef srand
-#undef rand
-
-    {
-        int test_count;
-        srand(123141);          // time(NULL));
-        for (test_count = 0; test_count < 100; test_count++) {
-            int size = rand() % 1024;
-            int ii;
-            uint8_t *data;
-            char *encoded_result;
-
-            av_log(NULL, AV_LOG_ERROR, "Test %d: Size %d bytes...",
-                   test_count, size);
-            data = (uint8_t *) av_malloc(size);
-            for (ii = 0; ii < size; ii++) {
-                data[ii] = rand() % 255;
-            }
-
-            encoded_result = av_base64_encode(data, size);
-            if (encoded_result) {
-                int decode_buffer_size = size + 10;     // try without 10 as well
-                uint8_t *decode_buffer = av_malloc(decode_buffer_size);
-                if (decode_buffer) {
-                    int decoded_size =
-                        av_base64_decode(decode_buffer, encoded_result,
-                                   decode_buffer_size);
-
-                    if (decoded_size != size) {
-                        av_log(NULL, AV_LOG_ERROR,
-                               "Decoded/Encoded size mismatch (%d != %d)\n",
-                               decoded_size, size);
-                    } else {
-                        if (memcmp(decode_buffer, data, decoded_size) == 0) {
-                            av_log(NULL, AV_LOG_ERROR, "Passed!\n");
-                        } else {
-                            av_log(NULL, AV_LOG_ERROR,
-                                   "Failed (Data differs)!\n");
-                        }
-                    }
-                    av_free(decode_buffer);
-                }
-
-                av_free(encoded_result);
-            }
-        }
-    }
-
-    // these are invalid strings, that it currently decodes (which it probably shouldn't?)
-    {
-        uint8_t str[32];
-        if (av_base64_decode(str, "M=M=", sizeof(str)) != -1) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "failed test %d: successful decode of `M=M='\n",
-                   numtest++);
-            numerr++;
-        }
-        if (av_base64_decode(str, "MQ===", sizeof(str)) != -1) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "failed test %d: successful decode of `MQ==='\n",
-                   numtest++);
-            numerr++;
-        }
-    }
-
-    return numerr;
-}
-#endif
-




More information about the ffmpeg-cvslog mailing list