~ubuntu-branches/ubuntu/quantal/aria2/quantal

« back to all changes in this revision

Viewing changes to test/XmlRpcRequestProcessorTest.cc

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry
  • Date: 2011-05-26 22:22:12 UTC
  • mfrom: (2.5.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110526222212-8ck4ia81l227m44l
Tags: 1.11.2-1
* New upstream release
* debian/control:
  + Updated Standards-Version to 3.9.2
* debian/copyright:
  + Updated as per latest DEP-5 specification

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
  CPPUNIT_TEST_SUITE(XmlRpcRequestProcessorTest);
15
15
  CPPUNIT_TEST(testParseMemory);
16
16
  CPPUNIT_TEST(testParseMemory_shouldFail);
 
17
  CPPUNIT_TEST(testParseMemory_withoutStringTag);
17
18
  CPPUNIT_TEST_SUITE_END();
18
19
public:
19
20
  void setUp() {}
22
23
 
23
24
  void testParseMemory();
24
25
  void testParseMemory_shouldFail();
 
26
  void testParseMemory_withoutStringTag();
25
27
};
26
28
 
27
29
 
114
116
  }
115
117
}
116
118
 
 
119
void XmlRpcRequestProcessorTest::testParseMemory_withoutStringTag()
 
120
{
 
121
  XmlRpcRequestProcessor proc;
 
122
  RpcRequest req =
 
123
    proc.parseMemory("<?xml version=\"1.0\"?>"
 
124
                     "<methodCall>"
 
125
                     "  <methodName>aria2.addUri</methodName>"
 
126
                     "    <params>"
 
127
                     "      <param>"
 
128
                     "        <value>http://aria2.sourceforge.net</value>"
 
129
                     "      </param>"
 
130
                     "      <param>"
 
131
                     "        <value>http://aria2.<foo/>sourceforge.net</value>"
 
132
                     "      </param>"
 
133
                     "      <param>"
 
134
                     "       <value>"
 
135
                     "         <struct>"
 
136
                     "           <member>"
 
137
                     "             <name>hello</name>"
 
138
                     "             <value>world</value>"
 
139
                     "           </member>"
 
140
                     "         </struct>"
 
141
                     "       </value>"
 
142
                     "     </param>"
 
143
                     "     <param>"
 
144
                     "       <value>"
 
145
                     "         <array>"
 
146
                     "           <data>"
 
147
                     "             <value>apple</value>"
 
148
                     "             <value>banana</value>"
 
149
                     "             <value><string>lemon</string>peanuts</value>"
 
150
                     "           </data>"
 
151
                     "         </array>"
 
152
                     "       </value>"
 
153
                     "     </param>"
 
154
                     "   </params>"
 
155
                     "</methodCall>");
 
156
 
 
157
  CPPUNIT_ASSERT_EQUAL((size_t)4, req.params->size());
 
158
  CPPUNIT_ASSERT_EQUAL(std::string("http://aria2.sourceforge.net"),
 
159
                       asString(req.params->get(0))->s());
 
160
  CPPUNIT_ASSERT_EQUAL(std::string("http://aria2.sourceforge.net"),
 
161
                       asString(req.params->get(1))->s());
 
162
  const Dict* dict = asDict(req.params->get(2));
 
163
  CPPUNIT_ASSERT_EQUAL(std::string("world"),
 
164
                       asString(dict->get("hello"))->s());
 
165
  const List* list = asList(req.params->get(3));
 
166
  CPPUNIT_ASSERT_EQUAL(std::string("apple"), asString(list->get(0))->s());
 
167
  CPPUNIT_ASSERT_EQUAL(std::string("banana"), asString(list->get(1))->s());
 
168
  CPPUNIT_ASSERT_EQUAL(std::string("lemon"), asString(list->get(2))->s());
 
169
}
 
170
 
117
171
} // namespace rpc
118
172
 
119
173
} // namespace aria2