Changeset 8549e2b01bf212c0facd441547eeed58aa4e7a81

Show
Ignore:
Timestamp:
04/11/06 17:47:52 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1144770472 +0000
git-parent:

[55687512c44c67ea54e9e14858a653066c105a37]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1144770472 +0000
Message:

Additionnal unit test for decode_URI

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/test/url.c

    rb40cd0c r8549e2b  
    2323#include "vlc_url.h" 
    2424 
    25 #undef NDEBUG 
    26 #include <assert.h> 
     25#include <stdio.h> 
     26#include <stdlib.h> 
     27 
     28void test_decode (const char *in, const char *out) 
     29
     30    char *res; 
     31 
     32    printf ("\"%s\" -> \"%s\" ?\n", in, out); 
     33    res = decode_URI_duplicate (in); 
     34    if (res == NULL) 
     35        exit (1); 
     36 
     37    if (strcmp (res, out)) 
     38        exit (2); 
     39 
     40    free (res); 
     41
    2742 
    2843int main (void) 
    2944{ 
    30     const char url1[] = "this_should_not_be_modified_1234"
    31     const char url2[] = "This+should+be+modified+1234!"; 
    32     const char url3[] = "This%20should%20be%20modified%201234!"
     45    (void)setvbuf (stdout, NULL, _IONBF, 0)
     46    test_decode ("this_should_not_be_modified_1234", 
     47                 "this_should_not_be_modified_1234")
    3348 
    34     char *durl = decode_URI_duplicate (url1); 
    35     assert (durl != NULL); 
    36     assert (!strcmp (durl, url1)); 
    37     free (durl); 
     49    test_decode ("This+should+be+modified+1234!", 
     50                 "This should be modified 1234!"); 
    3851 
    39     durl = decode_URI_duplicate (url2); 
    40     assert (durl != NULL); 
    41     assert (!strcmp (durl, "This should be modified 1234!")); 
    42     free (durl); 
     52    test_decode ("This%20should%20be%20modified%201234!", 
     53                 "This should be modified 1234!"); 
    4354 
    44     durl = decode_URI_duplicate (url3); 
    45     assert (durl != NULL); 
    46     assert (!strcmp (durl, "This should be modified 1234!")); 
    47     free (durl); 
     55    /* tests with invalid input */ 
     56    test_decode ("%", "%"); 
     57    test_decode ("%2", "%2"); 
     58    test_decode ("%0000", ""); 
     59 
     60    /* UTF-8 tests */ 
     61    test_decode ("T%C3%a9l%c3%A9vision", "Télévision"); 
     62    test_decode ("T%E9l%E9vision", "T?l?vision"); 
    4863 
    4964    return 0;