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
|
// HTML special symbols (<, >, &, ", and ') must be HTML-escaped
|
||||||
// Backslash symbols (\) must be duplicated.
|
// Backslash symbols (\) must be duplicated.
|
||||||
const std::string SPECIAL_CHARS(R"(\<>&'")");
|
const std::string SYMBOLS(R"(\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?)");
|
||||||
{
|
{
|
||||||
kiwix::Suggestions s;
|
kiwix::Suggestions s;
|
||||||
s.add(zim::SuggestionItem("Title with " + SPECIAL_CHARS,
|
s.add(zim::SuggestionItem("Title with " + SYMBOLS,
|
||||||
"Path with " + SPECIAL_CHARS,
|
"Path with " + SYMBOLS,
|
||||||
"Snippet with " + SPECIAL_CHARS));
|
"Snippet with " + SYMBOLS));
|
||||||
|
|
||||||
CHECK_SUGGESTIONS(s.getJSON(),
|
CHECK_SUGGESTIONS(s.getJSON(),
|
||||||
R"EXPECTEDJSON([
|
R"EXPECTEDJSON([
|
||||||
{
|
{
|
||||||
"value" : "Title with \\<>&'"",
|
"value" : "Title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||||
"label" : "Snippet with \\<>&'"",
|
"label" : "Snippet with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||||
"kind" : "path"
|
"kind" : "path"
|
||||||
, "path" : "Path with \\<>&'""
|
, "path" : "Path with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
)EXPECTEDJSON"
|
)EXPECTEDJSON"
|
||||||
|
@ -121,16 +121,16 @@ R"EXPECTEDJSON([
|
||||||
|
|
||||||
{
|
{
|
||||||
kiwix::Suggestions s;
|
kiwix::Suggestions s;
|
||||||
s.add(zim::SuggestionItem("Snippetless title with " + SPECIAL_CHARS,
|
s.add(zim::SuggestionItem("Snippetless title with " + SYMBOLS,
|
||||||
"Path with " + SPECIAL_CHARS));
|
"Path with " + SYMBOLS));
|
||||||
|
|
||||||
CHECK_SUGGESTIONS(s.getJSON(),
|
CHECK_SUGGESTIONS(s.getJSON(),
|
||||||
R"EXPECTEDJSON([
|
R"EXPECTEDJSON([
|
||||||
{
|
{
|
||||||
"value" : "Snippetless title with \\<>&'"",
|
"value" : "Snippetless title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||||
"label" : "Snippetless title with \\<>&'"",
|
"label" : "Snippetless title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?",
|
||||||
"kind" : "path"
|
"kind" : "path"
|
||||||
, "path" : "Path with \\<>&'""
|
, "path" : "Path with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
)EXPECTEDJSON"
|
)EXPECTEDJSON"
|
||||||
|
@ -139,13 +139,13 @@ R"EXPECTEDJSON([
|
||||||
|
|
||||||
{
|
{
|
||||||
kiwix::Suggestions s;
|
kiwix::Suggestions s;
|
||||||
s.addFTSearchSuggestion("eng", "text with " + SPECIAL_CHARS);
|
s.addFTSearchSuggestion("eng", "text with " + SYMBOLS);
|
||||||
|
|
||||||
CHECK_SUGGESTIONS(s.getJSON(),
|
CHECK_SUGGESTIONS(s.getJSON(),
|
||||||
R"EXPECTEDJSON([
|
R"EXPECTEDJSON([
|
||||||
{
|
{
|
||||||
"value" : "text with \\<>&'" ",
|
"value" : "text with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.? ",
|
||||||
"label" : "containing 'text with \\<>&'"'...",
|
"label" : "containing 'text with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?'...",
|
||||||
"kind" : "pattern"
|
"kind" : "pattern"
|
||||||
//EOLWHITESPACEMARKER
|
//EOLWHITESPACEMARKER
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue