mirror of https://github.com/kiwix/libkiwix.git
All non-alphanumeric symbols deserve a test
This commit is contained in:
parent
4966f4155d
commit
7743e73ede
|
@ -99,20 +99,20 @@ TEST(Suggestions, specialCharHandling)
|
|||
{
|
||||
// HTML special symbols (<, >, &, ", and ') must be HTML-escaped
|
||||
// Backslash symbols (\) must be duplicated.
|
||||
const std::string SPECIAL_CHARS(R"(\<>&'")");
|
||||
const std::string SYMBOLS(R"(\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?)");
|
||||
{
|
||||
kiwix::Suggestions s;
|
||||
s.add(zim::SuggestionItem("Title with " + SPECIAL_CHARS,
|
||||
"Path with " + SPECIAL_CHARS,
|
||||
"Snippet with " + SPECIAL_CHARS));
|
||||
s.add(zim::SuggestionItem("Title with " + SYMBOLS,
|
||||
"Path with " + SYMBOLS,
|
||||
"Snippet with " + SYMBOLS));
|
||||
|
||||
CHECK_SUGGESTIONS(s.getJSON(),
|
||||
R"EXPECTEDJSON([
|
||||
{
|
||||
"value" : "Title with \\<>&'"",
|
||||
"label" : "Snippet with \\<>&'"",
|
||||
"value" : "Title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||
"label" : "Snippet with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||
"kind" : "path"
|
||||
, "path" : "Path with \\<>&'""
|
||||
, "path" : "Path with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?"
|
||||
}
|
||||
]
|
||||
)EXPECTEDJSON"
|
||||
|
@ -121,16 +121,16 @@ R"EXPECTEDJSON([
|
|||
|
||||
{
|
||||
kiwix::Suggestions s;
|
||||
s.add(zim::SuggestionItem("Snippetless title with " + SPECIAL_CHARS,
|
||||
"Path with " + SPECIAL_CHARS));
|
||||
s.add(zim::SuggestionItem("Snippetless title with " + SYMBOLS,
|
||||
"Path with " + SYMBOLS));
|
||||
|
||||
CHECK_SUGGESTIONS(s.getJSON(),
|
||||
R"EXPECTEDJSON([
|
||||
{
|
||||
"value" : "Snippetless title with \\<>&'"",
|
||||
"label" : "Snippetless title with \\<>&'"",
|
||||
"value" : "Snippetless title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||
"label" : "Snippetless title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||
"kind" : "path"
|
||||
, "path" : "Path with \\<>&'""
|
||||
, "path" : "Path with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?"
|
||||
}
|
||||
]
|
||||
)EXPECTEDJSON"
|
||||
|
@ -139,13 +139,13 @@ R"EXPECTEDJSON([
|
|||
|
||||
{
|
||||
kiwix::Suggestions s;
|
||||
s.addFTSearchSuggestion("eng", "text with " + SPECIAL_CHARS);
|
||||
s.addFTSearchSuggestion("eng", "text with " + SYMBOLS);
|
||||
|
||||
CHECK_SUGGESTIONS(s.getJSON(),
|
||||
R"EXPECTEDJSON([
|
||||
{
|
||||
"value" : "text with \\<>&'" ",
|
||||
"label" : "containing 'text with \\<>&'"'...",
|
||||
"value" : "text with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.? ",
|
||||
"label" : "containing 'text with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?'...",
|
||||
"kind" : "pattern"
|
||||
//EOLWHITESPACEMARKER
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue