Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
33094be8
Commit
33094be8
authored
Feb 06, 2009
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove broken test program.
Originally committed as revision 17024 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
18c7b354
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
126 deletions
+0
-126
base64.c
libavutil/base64.c
+0
-126
No files found.
libavutil/base64.c
View file @
33094be8
...
@@ -98,129 +98,3 @@ char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len)
...
@@ -98,129 +98,3 @@ char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len)
return
ret
;
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment