~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/extract-uri-test.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
class ExtractURITest : public CxxTest::TestSuite
10
10
{
11
11
public:
 
12
    void checkOne( char const* str, char const* expected )
 
13
    {
 
14
        gchar* result = extract_uri( str );
 
15
        TS_ASSERT_EQUALS( ( result == NULL ), ( expected == NULL ) );
 
16
        if ( result && expected ) {
 
17
            TS_ASSERT_EQUALS( std::string(result), std::string(expected) );
 
18
        } else if ( result ) {
 
19
            TS_FAIL( std::string("Expected null, found (") + result + ")" );
 
20
        } else if ( expected ) {
 
21
            TS_FAIL( std::string("Expected (") + expected + "), found null" );
 
22
        }
 
23
        g_free( result );
 
24
    }
 
25
 
12
26
    void testBase()
13
27
    {
14
28
        char const* cases[][2] = {
15
29
            { "url(#foo)", "#foo" },
16
 
            { "url  foo  ", "foo" },
 
30
            { "url  foo  ", NULL },
17
31
            { "url", NULL },
18
32
            { "url ", NULL },
19
33
            { "url()", NULL },
20
34
            { "url ( ) ", NULL },
21
 
            { "url foo bar ", "foo bar" }
22
 
        };
23
 
 
24
 
        for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ )
25
 
        {
26
 
            char const* result = extract_uri( cases[i][0] );
27
 
 
28
 
            TS_ASSERT_EQUALS( ( result == NULL ), ( cases[i][1] == NULL ) );
29
 
            if ( result )
30
 
            {
31
 
                TS_ASSERT_EQUALS( std::string(result), std::string(cases[i][1]) );
32
 
            }
 
35
            { "url foo bar ", NULL },
 
36
        };
 
37
 
 
38
        for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ )
 
39
        {
 
40
            checkOne( cases[i][0], cases[i][1] );
 
41
        }
 
42
    }
 
43
 
 
44
    void testWithTrailing()
 
45
    {
 
46
        char const* cases[][2] = {
 
47
            { "url(#foo) bar", "#foo" },
 
48
            { "url() bar", NULL },
 
49
            { "url ( ) bar ", NULL }
 
50
        };
 
51
 
 
52
        for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ )
 
53
        {
 
54
            checkOne( cases[i][0], cases[i][1] );
 
55
        }
 
56
    }
 
57
 
 
58
    void testQuoted()
 
59
    {
 
60
        char const* cases[][2] = {
 
61
            { "url('#foo')", "#foo" },
 
62
            { "url(\"#foo\")", "#foo" },
 
63
            { "url('#f o o')", "#f o o" },
 
64
            { "url(\"#f o o\")", "#f o o" },
 
65
            { "url('#fo\"o')", "#fo\"o" },
 
66
            { "url(\"#fo'o\")", "#fo'o" },
 
67
        };
 
68
 
 
69
        for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ )
 
70
        {
 
71
            checkOne( cases[i][0], cases[i][1] );
33
72
        }
34
73
    }
35
74