cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=39dcf0e55aa76be1f0b9dbdb66bb95241b502b45

commit 39dcf0e55aa76be1f0b9dbdb66bb95241b502b45
Author: Srivardhan Hebbar <sri.heb...@samsung.com>
Date:   Mon Jan 4 15:20:04 2016 -0800

    eina: add test case for eina_base64url_decode API.
    
    Summary:
    Depends on D3521
    
    Signed-off-by: Srivardhan Hebbar <sri.heb...@samsung.com>
    
    Reviewers: cedric, jpeg
    
    Differential Revision: https://phab.enlightenment.org/D3522
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/tests/eina/eina_test_str.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/tests/eina/eina_test_str.c b/src/tests/eina/eina_test_str.c
index b0f98d1..ecb71fe 100644
--- a/src/tests/eina/eina_test_str.c
+++ b/src/tests/eina/eina_test_str.c
@@ -423,9 +423,11 @@ START_TEST(str_base64_encode_decode)
 }
 END_TEST
 
-START_TEST(str_base64url_encode)
+START_TEST(str_base64url_encode_decode)
 {
    unsigned int i;
+   int len;
+   unsigned char *decoded;
 
    for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
      {
@@ -433,8 +435,23 @@ START_TEST(str_base64url_encode)
 
         encoded = eina_str_base64url_encode((unsigned char*) 
tests[i].decoded_str, tests[i].len);
         fail_if(strcmp(encoded, tests[i].encoded_url));
+
+        decoded = eina_str_base64url_decode(tests[i].encoded_url, &len);
+        fail_if(memcmp(decoded, tests[i].decoded_str, tests[i].len));
+
+        fprintf(stderr, "len = %d, tests[%d].len = %d\n", len, i, 
tests[i].len);
+        fail_if(len != (int)tests[i].len);
+
         free(encoded);
+        free(decoded);
      }
+
+   //Failure scenarios.
+   decoded = eina_str_base64url_decode(NULL, &len);
+   fail_if(decoded);
+
+   decoded = eina_str_base64url_decode("TWFu", NULL);
+   fail_if(memcmp(decoded, "Man", 3));
 }
 END_TEST
 
@@ -478,7 +495,7 @@ eina_test_str(TCase *tc)
    tcase_add_test(tc, str_memdup);
    tcase_add_test(tc, str_strftime);
    tcase_add_test(tc, str_base64_encode_decode);
-   tcase_add_test(tc, str_base64url_encode);
+   tcase_add_test(tc, str_base64url_encode_decode);
 #ifdef HAVE_ICONV
    tcase_add_test(tc, str_convert);
 #endif

-- 


Reply via email to