Skip to content

Commit

Permalink
修复一个 = 号操作符的问题,完善一下test函数
Browse files Browse the repository at this point in the history
  • Loading branch information
yirenyiai committed Apr 1, 2015
1 parent 3c57e5e commit 47d41c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ build/
*.exp
*.opensdf
*.suo
*.ilk

# windows
[Dd]ebug/
[Rr]elease/
[Bb]bin/
[Bb]oost/
lib/boost/*
*.ilk


2 changes: 1 addition & 1 deletion src/html5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ bool html::basic_selector<CharType>::condition::operator()(const html::basic_dom
if (it == d.attributes.end()) return false;

if (matching_attr_operator == operator_string_equalityt<CharType>())
strcmp_ignore_case(it->second, matching_attr_value);
return strcmp_ignore_case(it->second, matching_attr_value);
else if (matching_attr_operator == operator_string_contain<CharType>())
{
if (matching_attr_value == selector_empty_string<CharType>()) return it->second.empty();
Expand Down
17 changes: 13 additions & 4 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


const char msg_usage[] = "\nusage : %s <html file name> <selector>\n\n";

// 如果你不希望跑命令行解析。那么你可以直接调用这个函数跑一下。
void test();


Expand All @@ -15,7 +17,6 @@ void callback(std::shared_ptr<html::dom>)

int main(int argc, char *argv[])
{
test();
if (argc < 3)
{
if (argc > 0)
Expand Down Expand Up @@ -60,14 +61,22 @@ void test()
html::dom page_href_http_node;

page.append_partial_html("<html><head>");
page.append_partial_html("<title id=\"1111\" href=\"http://www.baidu.com\">hello world</title");
page.append_partial_html("<title id=\"id_test\" href=\"http://www.baidu.com\" bkcolor=\"ff000000\" textcolor=\"ffffffff\">hello world</title");
page.append_partial_html("></head></html>");

//page["[href='#']"];
//page["[href!='#']"];
page = page["#id_test"];
printf("value : %s \n", page.to_plain_text().c_str());

page["[href]"];
printf("value : %s \n", page.to_plain_text().c_str());

page = page["[href$='http']"];
printf("value : %s \n", page.to_plain_text().c_str());

page = page["[bkcolor='ff000000']"];
printf("value : %s \n", page.to_plain_text().c_str());

page = page["[textcolor!='ff000000']"];
printf("value : %s \n", page.to_plain_text().c_str());

}

0 comments on commit 47d41c4

Please sign in to comment.