diff options
author | Steven Liu <lq@chinaffmpeg.org> | 2017-04-11 10:54:35 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2017-04-11 10:54:35 +0800 |
commit | 44cd7502c739a97f9b37319f208e1bcc5b1899fd (patch) | |
tree | 6c878a0ef02c18b3dd94cd4ffdea944bac9b9c03 /libavutil/tests/avstring.c | |
parent | a44b3abb4cf922e379fbac55452d0482a8223597 (diff) |
avutil/avstring: improve av_strreplace implement
Use AVBprint to implement av_strreplace
add av_strreplace test case TEST_STRREPLACE
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavutil/tests/avstring.c')
-rw-r--r-- | libavutil/tests/avstring.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libavutil/tests/avstring.c b/libavutil/tests/avstring.c index 14bc7ffcea..887bd25a12 100644 --- a/libavutil/tests/avstring.c +++ b/libavutil/tests/avstring.c @@ -93,6 +93,22 @@ int main(void) TEST_STRNSTR(haystack, needle [2], strlen(haystack), NULL ); TEST_STRNSTR(haystack, strings[1], strlen(haystack), haystack ); + /*Testing av_strireplace()*/ + #define TEST_STRIREPLACE(haystack, needle, expected) \ + ptr = av_strireplace(haystack, needle, "instead"); \ + if (ptr == NULL) { \ + printf("error, received null pointer!\n"); \ + } else { \ + if (strcmp(ptr, expected) != 0) \ + printf( "expected: %s, received: %s\n", expected, ptr); \ + av_free(ptr); \ + } + + TEST_STRIREPLACE(haystack, needle [0], "Education consists mainly in what we have uninstead"); + TEST_STRIREPLACE(haystack, needle [1], "Education consists mainly in what we have instead"); + TEST_STRIREPLACE(haystack, needle [2], "Education consists mainly in what we have instead."); + TEST_STRIREPLACE(haystack, needle [1], "Education consists mainly in what we have instead"); + /*Testing av_d2str()*/ #define TEST_D2STR(value, expected) \ if((ptr = av_d2str(value)) == NULL){ \ |