aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2009-02-06 23:24:17 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2009-02-06 23:24:17 +0000
commit33094be89424a3fd186e7b58314bf16352102150 (patch)
treeedd702523496d1fdd083a5ae07f5fc2b28d94cc3 /libavutil
parent18c7b354c5cf9d5656cdb500ed3afef3628125ca (diff)
downloadffmpeg-33094be89424a3fd186e7b58314bf16352102150.tar.gz
Remove broken test program.
Originally committed as revision 17024 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/base64.c126
1 files changed, 0 insertions, 126 deletions
diff --git a/libavutil/base64.c b/libavutil/base64.c
index 06fe5407e2..91a5d23005 100644
--- a/libavutil/base64.c
+++ b/libavutil/base64.c
@@ -98,129 +98,3 @@ char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len)
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
-