~autopilot/xpathselect/1.3

« back to all changes in this revision

Viewing changes to test/test_xpath_tree.cpp

  • Committer: Tarmac
  • Author(s): Thomi Richards
  • Date: 2013-01-18 03:25:00 UTC
  • mfrom: (25.1.9 trunk)
  • Revision ID: tarmac-20130118032500-2bhgu0n9r1tl0a62
Add capability for searching sub-trees with '//'.

Approved by PS Jenkins bot, Christopher Lee.

Show diffs side-by-side

added added

removed removed

Lines of Context:
143
143
    ASSERT_EQ(1, result.size());
144
144
    ASSERT_EQ(child_l1_, result.front());
145
145
}
 
146
 
 
147
TEST_F(TestTreeFixture, test_mixed_query_simple)
 
148
{
 
149
    xpathselect::NodeList result = xpathselect::SelectNodes(root_, "/Root//Leaf");
 
150
    ASSERT_EQ(2, result.size());
 
151
    for(auto n : result)
 
152
    {
 
153
        ASSERT_TRUE(n == leaf_1_ || n == leaf_2_ );
 
154
    }
 
155
}
 
156
 
 
157
TEST_F(TestTreeFixture, test_wildcard)
 
158
{
 
159
    xpathselect::NodeList result = xpathselect::SelectNodes(root_, "/Root/*");
 
160
    ASSERT_EQ(2, result.size());
 
161
    for(auto n : result)
 
162
    {
 
163
        ASSERT_TRUE(n == child_l1_ || n == child_r1_ );
 
164
    }
 
165
}
 
166
 
 
167
TEST_F(TestTreeFixture, test_invalid_query_search_at_end)
 
168
{
 
169
    xpathselect::NodeList result = xpathselect::SelectNodes(root_, "/Root///Leaf");
 
170
    ASSERT_EQ(0, result.size());
 
171
}
 
172
 
 
173
TEST_F(TestTreeFixture, test_invalid_query_multiple_searches)
 
174
{
 
175
    xpathselect::NodeList result = xpathselect::SelectNodes(root_, "/Root////");
 
176
    ASSERT_EQ(0, result.size());
 
177
}