~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/xml/quote-test.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cxxtest/TestSuite.h>
 
2
#include "streq.h"
 
3
 
 
4
/* Initial author: Peter Moulder.
 
5
   Hereby released into the Public Domain. */
 
6
 
 
7
#include <cstring>
 
8
#include <functional>
 
9
 
 
10
/* mental disclaims all responsibility for this evil idea for testing
 
11
   static functions.  The main disadvantages are that we retain any
 
12
   #define's and `using' directives of the included file. */
 
13
#include "quote.cpp"
 
14
 
 
15
class XmlQuoteTest : public CxxTest::TestSuite
 
16
{
 
17
public:
 
18
 
 
19
    XmlQuoteTest()
 
20
    {
 
21
    }
 
22
    virtual ~XmlQuoteTest() {}
 
23
 
 
24
// createSuite and destroySuite get us per-suite setup and teardown
 
25
// without us having to worry about static initialization order, etc.
 
26
    static XmlQuoteTest *createSuite() { return new XmlQuoteTest(); }
 
27
    static void destroySuite( XmlQuoteTest *suite ) { delete suite; }
 
28
 
 
29
    void testXmlQuotedStrlen()
 
30
    {
 
31
        struct {
 
32
            char const *s;
 
33
            size_t len;
 
34
        } cases[] = {
 
35
            {"", 0},
 
36
            {"x", 1},
 
37
            {"Foo", 3},
 
38
            {"\"", 6},
 
39
            {"&", 5},
 
40
            {"<", 4},
 
41
            {">", 4},
 
42
            {"a\"b", 8},
 
43
            {"a\"b<c>d;!@#$%^*(\\)?", 30}
 
44
        };
 
45
        for(size_t i=0; i<G_N_ELEMENTS(cases); i++) {
 
46
            TS_ASSERT_EQUALS( xml_quoted_strlen(cases[i].s) , cases[i].len );
 
47
        }
 
48
    }
 
49
 
 
50
    void testXmlQuoteStrdup()
 
51
    {
 
52
        struct {
 
53
            char const * s1;
 
54
            char const * s2;
 
55
        } cases[] = {
 
56
            {"", ""},
 
57
            {"x", "x"},
 
58
            {"Foo", "Foo"},
 
59
            {"\"", "&quot;"},
 
60
            {"&", "&amp;"},
 
61
            {"<", "&lt;"},
 
62
            {">", "&gt;"},
 
63
            {"a\"b<c>d;!@#$%^*(\\)?", "a&quot;b&lt;c&gt;d;!@#$%^*(\\)?"}
 
64
        };
 
65
        for(size_t i=0; i<G_N_ELEMENTS(cases); i++) {
 
66
            char* str = xml_quote_strdup(cases[i].s1);
 
67
            TS_ASSERT_RELATION( streq_rel, cases[i].s2, str );
 
68
            g_free(str);
 
69
        }
 
70
    }
 
71
};
 
72
 
 
73
/*
 
74
  Local Variables:
 
75
  mode:c++
 
76
  c-file-style:"stroustrup"
 
77
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
78
  indent-tabs-mode:nil
 
79
  fill-column:99
 
80
  End:
 
81
*/
 
82
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :