mirror of
https://github.com/kiwix/libkiwix.git
synced 2026-02-18 23:24:00 -05:00
Compare commits
1 Commits
main
...
multiple_s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75a336395a |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -69,7 +69,7 @@ jobs:
|
||||
run: meson test -C build --verbose
|
||||
|
||||
Windows:
|
||||
runs-on: windows-2025
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
||||
@@ -32,7 +32,7 @@ class Archive;
|
||||
|
||||
namespace Xapian
|
||||
{
|
||||
class Database;
|
||||
class WritableDatabase;
|
||||
}
|
||||
|
||||
namespace kiwix
|
||||
@@ -50,7 +50,7 @@ public: // functions
|
||||
std::vector<std::string> getSpellingCorrections(const std::string& word, uint32_t maxCount) const;
|
||||
|
||||
private: // data
|
||||
std::unique_ptr<Xapian::Database> impl_;
|
||||
std::unique_ptr<Xapian::WritableDatabase> impl_;
|
||||
};
|
||||
|
||||
} // namespace kiwix
|
||||
|
||||
@@ -242,7 +242,7 @@ const std::string& Book::Illustration::getData() const
|
||||
try {
|
||||
data = download(url);
|
||||
} catch(...) {
|
||||
std::cerr << "Cannot download favicon from " << url << std::endl;
|
||||
std::cerr << "Cannot download favicon from " << url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +346,11 @@ SearchInfo InternalServer::getSearchInfo(const RequestContext& request) const
|
||||
geoQuery = GeoQuery(latitude, longitude, distance);
|
||||
} catch(const std::out_of_range&) {}
|
||||
catch(const std::invalid_argument&) {}
|
||||
|
||||
if (!geoQuery && pattern.empty()) {
|
||||
throw Error(nonParameterizedMessage("no-query"));
|
||||
}
|
||||
|
||||
return SearchInfo(pattern, geoQuery, bookIds.second, bookIds.first);
|
||||
}
|
||||
|
||||
@@ -361,7 +366,7 @@ zim::Query SearchInfo::getZimQuery(bool verbose) const {
|
||||
if (verbose) {
|
||||
std::cout << "Performing query '" << pattern<< "'";
|
||||
}
|
||||
query.setQuery(kiwix::trim(pattern));
|
||||
query.setQuery(pattern);
|
||||
if (geoQuery) {
|
||||
if (verbose) {
|
||||
std::cout << " with geo query '" << geoQuery.distance << "&(" << geoQuery.latitude << ";" << geoQuery.longitude << ")'";
|
||||
|
||||
@@ -43,15 +43,11 @@ std::vector<std::string> getAllTitles(const zim::Archive& a)
|
||||
void createXapianDB(std::string path, const zim::Archive& archive)
|
||||
{
|
||||
const int flags = Xapian::DB_BACKEND_GLASS|Xapian::DB_CREATE;
|
||||
const auto tmpDbPath = path + ".tmp";
|
||||
Xapian::WritableDatabase db(tmpDbPath, flags);
|
||||
Xapian::WritableDatabase db(path, flags);
|
||||
for (const auto& t : getAllTitles(archive)) {
|
||||
db.add_spelling(t);
|
||||
}
|
||||
db.commit();
|
||||
db.compact(path, Xapian::DBCOMPACT_SINGLE_FILE);
|
||||
db.close();
|
||||
std::filesystem::remove_all(tmpDbPath);
|
||||
}
|
||||
|
||||
std::string spellingsDBPathForZIMArchive(std::filesystem::path cacheDirPath, const zim::Archive& a)
|
||||
@@ -59,24 +55,27 @@ std::string spellingsDBPathForZIMArchive(std::filesystem::path cacheDirPath, con
|
||||
// The version of spellings DB must be updated each time an important change
|
||||
// to the implementation is made that renders using the previous version
|
||||
// impossible or undesirable.
|
||||
const char SPELLINGS_DB_VERSION[] = "0.1";
|
||||
const char SPELLINGS_DB_VERSION[] = "0.2";
|
||||
|
||||
std::ostringstream filename;
|
||||
filename << a.getUuid() << ".spellingsdb.v" << SPELLINGS_DB_VERSION;
|
||||
return (cacheDirPath / filename.str()).string();
|
||||
}
|
||||
|
||||
std::unique_ptr<Xapian::Database> openOrCreateXapianDB(std::filesystem::path cacheDirPath, const zim::Archive& archive)
|
||||
std::unique_ptr<Xapian::WritableDatabase> openOrCreateXapianDB(std::filesystem::path cacheDirPath, const zim::Archive& archive)
|
||||
{
|
||||
const auto path = spellingsDBPathForZIMArchive(cacheDirPath, archive);
|
||||
try
|
||||
{
|
||||
return std::make_unique<Xapian::Database>(path);
|
||||
{
|
||||
Xapian::Database checkIfDbAlreadyExists(path);
|
||||
}
|
||||
return std::make_unique<Xapian::WritableDatabase>(path);
|
||||
}
|
||||
catch (const Xapian::DatabaseOpeningError& )
|
||||
{
|
||||
createXapianDB(path, archive);
|
||||
return std::make_unique<Xapian::Database>(path);
|
||||
return std::make_unique<Xapian::WritableDatabase>(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,15 +92,23 @@ SpellingsDB::~SpellingsDB()
|
||||
|
||||
std::vector<std::string> SpellingsDB::getSpellingCorrections(const std::string& word, uint32_t maxCount) const
|
||||
{
|
||||
if ( maxCount > 1 ) {
|
||||
throw std::runtime_error("More than one spelling correction was requested");
|
||||
std::vector<std::string> result;
|
||||
while ( result.size() < maxCount ) {
|
||||
const auto term = impl_->get_spelling_suggestion(word, 3);
|
||||
if ( term.empty() )
|
||||
break;
|
||||
|
||||
result.push_back(term);
|
||||
|
||||
// temporarily remove this term so that another spellings could be obtained
|
||||
impl_->remove_spelling(term);
|
||||
}
|
||||
|
||||
std::vector<std::string> result;
|
||||
const auto term = impl_->get_spelling_suggestion(word, 3);
|
||||
if ( !term.empty() ) {
|
||||
result.push_back(term);
|
||||
// restore temporarily removed terms
|
||||
for (const auto& t : result) {
|
||||
impl_->add_spelling(t);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
#include <unicode/uniset.h>
|
||||
#include <unicode/ustring.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <regex>
|
||||
@@ -451,11 +450,3 @@ std::string kiwix::getSlugifiedFileName(const std::string& filename)
|
||||
#endif
|
||||
return std::regex_replace(filename, reservedCharsReg, "_");
|
||||
}
|
||||
|
||||
std::string kiwix::trim(const std::string& s)
|
||||
{
|
||||
auto is_space = [](unsigned char c) { return std::isspace(c); };
|
||||
auto start = std::find_if_not(s.begin(), s.end(), is_space);
|
||||
auto end = std::find_if_not(s.rbegin(), s.rend(), is_space).base();
|
||||
return (start < end) ? std::string(start, end) : std::string();
|
||||
}
|
||||
|
||||
@@ -60,8 +60,6 @@ std::string escapeForJSON(const std::string& s, bool escapeQuote = true);
|
||||
std::string urlEncode(const std::string& value);
|
||||
std::string urlDecode(const std::string& value, bool component = false);
|
||||
|
||||
std::string trim(const std::string& s);
|
||||
|
||||
std::string join(const std::vector<std::string>& list, const std::string& sep);
|
||||
|
||||
std::string ucAll(const std::string& word);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"no-such-book": "Necun tal libro: {{BOOK_NAME}}",
|
||||
"too-many-books": "Troppo de libros demandate ({{NB_BOOKS}}); le limite es {{LIMIT}}",
|
||||
"no-book-found": "Necun libro corresponde al criterios de selection",
|
||||
"url-not-found": "Le URL requestate “{{url}}” non ha essite trovate sur iste servitor.",
|
||||
"url-not-found": "Le URL reuqestate \"{{url}}\" non ha essite trovate sur iste servitor.",
|
||||
"suggest-search": "Facer un recerca in texto complete de <a href=\"{{{SEARCH_URL}}}\">{{PATTERN}}</a>",
|
||||
"random-article-failure": "Ups! Non poteva eliger un articulo aleatori :(",
|
||||
"invalid-raw-data-type": "{{DATATYPE}} non es un requesta valide pro contento brute.",
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"Akmaie Ajam",
|
||||
"Bennylin",
|
||||
"Penyuwangi"
|
||||
"Akmaie Ajam"
|
||||
]
|
||||
},
|
||||
"name": "Bahasa Inggris",
|
||||
"suggest-full-text-search": "mengandung '{{{SEARCH_TERMS}}}'...",
|
||||
"no-such-book": "Tidak ada buku seperti ini: {{BOOK_NAME}}",
|
||||
"too-many-books": "Terlalu banyak buku yang diminta ({{NB_BOOKS}}), batasnya adalah {{LIMIT}}",
|
||||
"too-many-books": "Terlalu banyak buku yang diminta ({{NB_BOOKS}}) dimana batasnya adalah {{LIMIT}}",
|
||||
"no-book-found": "Tidak ada buku yang sesuai kriteria yang dipilih",
|
||||
"url-not-found": "URL yang diminta \"{{url}}\" tidak ditemukan di peladen ini.",
|
||||
"url-not-found": "URL yang diminta \"{{url}}\" tidak ditemukan di server ini.",
|
||||
"suggest-search": "Lakukan pencarian teks lengkap untuk <a href=\"{{{SEARCH_URL}}}\">{{PATTERN}}</a>",
|
||||
"random-article-failure": "Waduh! Gagal memilih artikel acak :(",
|
||||
"invalid-raw-data-type": "{{DATATYPE}} bukan permintaan yang sah untuk konten mentah.",
|
||||
@@ -23,9 +21,9 @@
|
||||
"400-page-heading": "Permintaan tidak sah",
|
||||
"404-page-title": "Konten tidak ditemukan",
|
||||
"404-page-heading": "Tidak Ditemukan",
|
||||
"500-page-title": "Galat Peladen Internal",
|
||||
"500-page-heading": "Aduh. Halaman tidak bekerja.",
|
||||
"500-page-text": "Jalur yang diminta tidak dapat diantar dengan benar:",
|
||||
"500-page-title": "Kesalahan Server Internal",
|
||||
"500-page-heading": "Kesalahan Server Internal",
|
||||
"500-page-text": "Terjadi kesalahan server internal. Kami mohon maaf atas hal ini :/",
|
||||
"fulltext-search-unavailable": "Pencarian teks lengkap tidak tersedia",
|
||||
"no-search-results": "Mesin pencari teks lengkap tidak tersedia untuk konten ini.",
|
||||
"search-results-page-title": "Pencarian: {{SEARCH_PATTERN}}",
|
||||
@@ -54,10 +52,10 @@
|
||||
"torrent-download-link-text": "BitTorrent",
|
||||
"torrent-download-alt-text": "Unduh melalui BitTorrent",
|
||||
"library-opds-feed-all-entries": "Umpan OPDS Perpustakaan - Semua entri",
|
||||
"filter-by-tag": "Saring berdasarkan tanda \"{{{TAG}}}\"",
|
||||
"stop-filtering-by-tag": "Hentikan penyaringan berdasarkan tanda \"{{{TAG}}}\"",
|
||||
"library-opds-feed-parameterised": "Umpan OPDS Perpustakaan - entri yang cocok dengan {{#LANG}}\nBahasa: {{LANG}} {{/LANG}}{{#CATEGORY}}\nKategori: {{CATEGORY}} {{/CATEGORY}}{{#TAG}}\nTanda: {{TAG}} {{/TAG}}{{#Q}}\nKueri: {{Q}} {{/Q}}",
|
||||
"welcome-to-kiwix-server": "Selamat datang di Peladen Kiwix",
|
||||
"filter-by-tag": "Saring berdasarkan tag \"{{{TAG}}}\"",
|
||||
"stop-filtering-by-tag": "Berhenti penyaringan berdasarkan tag \"{{{TAG}}}\"",
|
||||
"library-opds-feed-parameterised": "Umpan OPDS Perpustakaan - entri yang cocok dengan {{#LANG}}\nBahasa: {{LANG}} {{/LANG}}{{#CATEGORY}}\nKategori: {{CATEGORY}} {{/CATEGORY}}{{#TAG}}\nTag: {{TAG}} {{/TAG}}{{#Q}}\nKueri: {{Q}} {{/Q}}",
|
||||
"welcome-to-kiwix-server": "Selamat datang di Server Kiwix",
|
||||
"download-links-heading": "Tautan unduhan untuk <b><i>{{BOOK_TITLE}}</i></b>",
|
||||
"download-links-title": "Unduh buku",
|
||||
"preview-book": "Pratayang",
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
"direct-download-alt-text": "Direct downloaden via HTTP(S)",
|
||||
"hash-download-link-text": "SHA-256-controlesom",
|
||||
"hash-download-alt-text": "De SHA-256-controlesom van het bestand weergeven",
|
||||
"magnet-link-text": "Magnet-koppeling",
|
||||
"magnet-link-text": "Magnet-link",
|
||||
"magnet-alt-text": "Downloaden via Magnet-link",
|
||||
"torrent-download-link-text": "BitTorrent",
|
||||
"torrent-download-alt-text": "Downloaden via BitTorrent",
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"Lutece398",
|
||||
"Okras",
|
||||
"Pacha Tchernof",
|
||||
"Putnik",
|
||||
"Razno0",
|
||||
"Rofiatmustapha12",
|
||||
"Smavrina"
|
||||
@@ -60,7 +59,7 @@
|
||||
"torrent-download-link-text": "BitTorrent",
|
||||
"torrent-download-alt-text": "Скачать через BitTorrent",
|
||||
"library-opds-feed-all-entries": "Канал библиотеки OPDS – все записи",
|
||||
"filter-by-tag": "Фильтровать по тегу «{{{TAG}}}»",
|
||||
"filter-by-tag": "Фильтровать по тегу \"{{{TAG}}}\"",
|
||||
"stop-filtering-by-tag": "Прекратить фильтрацию по тегу \"{{{TAG}}}\"",
|
||||
"library-opds-feed-parameterised": "Канал OPDS библиотеки – записи, соответствующие {{#LANG}}\nLanguage: {{LANG}} {{/LANG}}{{#CATEGORY}}\nCategory: {{CATEGORY}} {{/CATEGORY}} {{#TAG}}\nTag: {{TAG}} {{/TAG}}{{#Q}}\nЗапрос: {{Q}} {{/Q}}",
|
||||
"welcome-to-kiwix-server": "Добро пожаловать на сервер Kiwix",
|
||||
|
||||
@@ -32,7 +32,7 @@ const uiLanguages = [
|
||||
{
|
||||
"iso_code": "el",
|
||||
"self_name": "Αγγλικά",
|
||||
"translation_count": 27
|
||||
"translation_count": 23
|
||||
},
|
||||
{
|
||||
"iso_code": "en",
|
||||
@@ -41,13 +41,13 @@ const uiLanguages = [
|
||||
},
|
||||
{
|
||||
"iso_code": "es",
|
||||
"self_name": "Español",
|
||||
"translation_count": 92
|
||||
"self_name": "español",
|
||||
"translation_count": 67
|
||||
},
|
||||
{
|
||||
"iso_code": "fi",
|
||||
"self_name": "suomi",
|
||||
"translation_count": 49
|
||||
"translation_count": 29
|
||||
},
|
||||
{
|
||||
"iso_code": "fr",
|
||||
@@ -117,12 +117,12 @@ const uiLanguages = [
|
||||
{
|
||||
"iso_code": "lb",
|
||||
"self_name": "Lëtzebuergesch",
|
||||
"translation_count": 49
|
||||
"translation_count": 48
|
||||
},
|
||||
{
|
||||
"iso_code": "mk",
|
||||
"self_name": "македонски",
|
||||
"translation_count": 92
|
||||
"translation_count": 81
|
||||
},
|
||||
{
|
||||
"iso_code": "ms",
|
||||
@@ -137,7 +137,7 @@ const uiLanguages = [
|
||||
{
|
||||
"iso_code": "nl",
|
||||
"self_name": "Nederlands",
|
||||
"translation_count": 84
|
||||
"translation_count": 68
|
||||
},
|
||||
{
|
||||
"iso_code": "nqo",
|
||||
@@ -192,7 +192,7 @@ const uiLanguages = [
|
||||
{
|
||||
"iso_code": "sl",
|
||||
"self_name": "slovenščina",
|
||||
"translation_count": 84
|
||||
"translation_count": 57
|
||||
},
|
||||
{
|
||||
"iso_code": "sq",
|
||||
@@ -202,7 +202,7 @@ const uiLanguages = [
|
||||
{
|
||||
"iso_code": "sv",
|
||||
"self_name": "Svenska",
|
||||
"translation_count": 84
|
||||
"translation_count": 67
|
||||
},
|
||||
{
|
||||
"iso_code": "sw",
|
||||
@@ -222,7 +222,7 @@ const uiLanguages = [
|
||||
{
|
||||
"iso_code": "zh-hans",
|
||||
"self_name": "简体中文",
|
||||
"translation_count": 84
|
||||
"translation_count": 68
|
||||
},
|
||||
{
|
||||
"iso_code": "zh-hant",
|
||||
|
||||
@@ -83,7 +83,6 @@ function quasiUriEncode(s, specialSymbols) {
|
||||
|
||||
function performSearch() {
|
||||
const searchbox = document.getElementById('kiwixsearchbox');
|
||||
if (!searchbox.value.trim()) { return;}
|
||||
const q = encodeURIComponent(searchbox.value);
|
||||
gotoUrl(`/search?books.name=${currentBook}&pattern=${q}&userlang=${viewerState.uiLanguage}`);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ const ResourceCollection resources200Compressible{
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/taskbar.css" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/taskbar.css?cacheid=42e90cb9" },
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/viewer.js" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/viewer.js?cacheid=6192cae1" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/viewer.js?cacheid=00e0fdf3" },
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/fonts/Poppins.ttf" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/fonts/Poppins.ttf?cacheid=af705837" },
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/fonts/Roboto.ttf" },
|
||||
@@ -86,7 +86,7 @@ const ResourceCollection resources200Compressible{
|
||||
// TODO: implement cache management of i18n resources
|
||||
//{ STATIC_CONTENT, "/ROOT%23%3F/skin/i18n/test.json?cacheid=unknown" },
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/languages.js" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/languages.js?cacheid=d2d6933b" },
|
||||
{ STATIC_CONTENT, "/ROOT%23%3F/skin/languages.js?cacheid=08955948" },
|
||||
|
||||
{ DYNAMIC_CONTENT, "/ROOT%23%3F/catalog/search" },
|
||||
|
||||
@@ -301,7 +301,7 @@ R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/kiwix.css?cacheid=b4e29e64"
|
||||
<meta name="msapplication-config" content="/ROOT%23%3F/skin/favicon/browserconfig.xml?cacheid=f29a7c4a">
|
||||
<script type="text/javascript" src="./skin/polyfills.js?cacheid=a0e0343d"></script>
|
||||
<script type="module" src="/ROOT%23%3F/skin/i18n.js?cacheid=e9a10ac1" defer></script>
|
||||
<script type="text/javascript" src="/ROOT%23%3F/skin/languages.js?cacheid=d2d6933b" defer></script>
|
||||
<script type="text/javascript" src="/ROOT%23%3F/skin/languages.js?cacheid=08955948" defer></script>
|
||||
<script src="/ROOT%23%3F/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script>
|
||||
<script src="/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3"></script>
|
||||
<script type="text/javascript" src="/ROOT%23%3F/skin/index.js?cacheid=4e232c58" defer></script>
|
||||
@@ -337,8 +337,8 @@ R"EXPECTEDRESULT( <link type="text/css" href="./skin/kiwix.css?cacheid=b4e29e
|
||||
<link type="text/css" href="./skin/print.css?cacheid=65b1c1d2" media="print" rel="Stylesheet" />
|
||||
<script type="text/javascript" src="./skin/polyfills.js?cacheid=a0e0343d"></script>
|
||||
<script type="module" src="./skin/i18n.js?cacheid=e9a10ac1" defer></script>
|
||||
<script type="text/javascript" src="./skin/languages.js?cacheid=d2d6933b" defer></script>
|
||||
<script type="text/javascript" src="./skin/viewer.js?cacheid=6192cae1" defer></script>
|
||||
<script type="text/javascript" src="./skin/languages.js?cacheid=08955948" defer></script>
|
||||
<script type="text/javascript" src="./skin/viewer.js?cacheid=00e0fdf3" defer></script>
|
||||
<script type="text/javascript" src="./skin/autoComplete/autoComplete.min.js?cacheid=1191aaaf"></script>
|
||||
const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032";
|
||||
<label for="kiwix_button_show_toggle"><img src="./skin/caret.png?cacheid=22b942b4" alt=""></label>
|
||||
@@ -438,6 +438,7 @@ TEST_F(ServerTest, CacheIdsOfStaticResourcesMatchTheSha1HashOfResourceContent)
|
||||
|
||||
const char* urls400[] = {
|
||||
"/ROOT%23%3F/search",
|
||||
"/ROOT%23%3F/search?content=zimfile",
|
||||
"/ROOT%23%3F/search?content=non-existing-book&pattern=asdfqwerty",
|
||||
"/ROOT%23%3F/search?content=non-existing-book&pattern=asd<qwerty",
|
||||
"/ROOT%23%3F/search?books.name=non-exsitent-book&pattern=asd<qwerty",
|
||||
@@ -1051,6 +1052,17 @@ TEST_F(ServerTest, Http400HtmlError)
|
||||
<p>
|
||||
Too many books requested (4) where limit is 3
|
||||
</p>
|
||||
)" },
|
||||
{ /* url */ "/ROOT%23%3F/search?content=zimfile",
|
||||
expected_kiwix_response_data==R"({ "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "400-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "400-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "invalid-request", "params" : { "url" : "/ROOT%23%3F/search?content=zimfile" } } }, { "p" : { "msgid" : "no-query", "params" : { } } } ] })" &&
|
||||
expected_body==R"(
|
||||
<h1>Invalid request</h1>
|
||||
<p>
|
||||
The requested URL "/ROOT%23%3F/search?content=zimfile" is not a valid request.
|
||||
</p>
|
||||
<p>
|
||||
No query provided.
|
||||
</p>
|
||||
)" },
|
||||
{ /* url */ "/ROOT%23%3F/search?content=non-existing-book&pattern=asdfqwerty",
|
||||
expected_kiwix_response_data==R"({ "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "400-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "400-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "invalid-request", "params" : { "url" : "/ROOT%23%3F/search?content=non-existing-book&pattern=asdfqwerty" } } }, { "p" : { "msgid" : "no-such-book", "params" : { "BOOK_NAME" : "non-existing-book" } } } ] })" &&
|
||||
@@ -1073,6 +1085,19 @@ TEST_F(ServerTest, Http400HtmlError)
|
||||
<p>
|
||||
No such book: non-existing-book
|
||||
</p>
|
||||
)" },
|
||||
// There is a flaw in our way to handle query string, we cannot differenciate
|
||||
// between `pattern` and `pattern=`
|
||||
{ /* url */ "/ROOT%23%3F/search?books.filter.lang=eng&pattern",
|
||||
expected_kiwix_response_data==R"({ "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "400-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "400-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "invalid-request", "params" : { "url" : "/ROOT%23%3F/search?books.filter.lang=eng&pattern" } } }, { "p" : { "msgid" : "no-query", "params" : { } } } ] })" &&
|
||||
expected_body==R"(
|
||||
<h1>Invalid request</h1>
|
||||
<p>
|
||||
The requested URL "/ROOT%23%3F/search?books.filter.lang=eng&pattern" is not a valid request.
|
||||
</p>
|
||||
<p>
|
||||
No query provided.
|
||||
</p>
|
||||
)" },
|
||||
{ /* url */ "/ROOT%23%3F/search?pattern=foo",
|
||||
expected_kiwix_response_data==R"({ "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "400-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "400-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "invalid-request", "params" : { "url" : "/ROOT%23%3F/search?pattern=foo" } } }, { "p" : { "msgid" : "too-many-books", "params" : { "LIMIT" : "3", "NB_BOOKS" : "4" } } } ] })" &&
|
||||
@@ -1085,6 +1110,20 @@ TEST_F(ServerTest, Http400HtmlError)
|
||||
Too many books requested (4) where limit is 3
|
||||
</p>
|
||||
)" },
|
||||
|
||||
// Testing of translation
|
||||
{ /* url */ "/ROOT%23%3F/search?content=zimfile&userlang=test",
|
||||
expected_page_title=="[I18N TESTING] Invalid request ($400 fine must be paid)" &&
|
||||
expected_kiwix_response_data==R"({ "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "400-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "400-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "invalid-request", "params" : { "url" : "/ROOT%23%3F/search?content=zimfile&userlang=test" } } }, { "p" : { "msgid" : "no-query", "params" : { } } } ] })" &&
|
||||
expected_body==R"(
|
||||
<h1>[I18N TESTING] -400 karma for an invalid request</h1>
|
||||
<p>
|
||||
[I18N TESTING] Invalid URL: "/ROOT%23%3F/search?content=zimfile&userlang=test"
|
||||
</p>
|
||||
<p>
|
||||
[I18N TESTING] Kiwix can read your thoughts but it is against GDPR. Please provide your query explicitly.
|
||||
</p>
|
||||
)" },
|
||||
};
|
||||
|
||||
for ( const auto& t : testData ) {
|
||||
@@ -1115,6 +1154,20 @@ TEST_F(ServerTest, HttpXmlError)
|
||||
};
|
||||
|
||||
const std::vector<TestData> testData{
|
||||
{ /* url */ "/ROOT%23%3F/search?format=xml",
|
||||
/* HTTP status code */ 400,
|
||||
/* expected response XML */ R"(
|
||||
<error>Invalid request</error>
|
||||
<detail>The requested URL "/ROOT%23%3F/search?format=xml" is not a valid request.</detail>
|
||||
<detail>Too many books requested (4) where limit is 3</detail>
|
||||
)" },
|
||||
{ /* url */ "/ROOT%23%3F/search?format=xml&content=zimfile",
|
||||
/* HTTP status code */ 400,
|
||||
/* expected response XML */ R"(
|
||||
<error>Invalid request</error>
|
||||
<detail>The requested URL "/ROOT%23%3F/search?format=xml&content=zimfile" is not a valid request.</detail>
|
||||
<detail>No query provided.</detail>
|
||||
)" },
|
||||
{ /* url */ "/ROOT%23%3F/search?format=xml&content=non-existing-book&pattern=asdfqwerty",
|
||||
/* HTTP status code */ 400,
|
||||
/* expected response XML */ R"(
|
||||
@@ -1128,6 +1181,15 @@ TEST_F(ServerTest, HttpXmlError)
|
||||
<error>Invalid request</error>
|
||||
<detail>The requested URL "/ROOT%23%3F/search?format=xml&content=non-existing-book&pattern=a%22%3Cscript%20foo%3E" is not a valid request.</detail>
|
||||
<detail>No such book: non-existing-book</detail>
|
||||
)" },
|
||||
// There is a flaw in our way to handle query string, we cannot differenciate
|
||||
// between `pattern` and `pattern=`
|
||||
{ /* url */ "/ROOT%23%3F/search?format=xml&books.filter.lang=eng&pattern",
|
||||
/* HTTP status code */ 400,
|
||||
/* expected response XML */ R"(
|
||||
<error>Invalid request</error>
|
||||
<detail>The requested URL "/ROOT%23%3F/search?format=xml&books.filter.lang=eng&pattern" is not a valid request.</detail>
|
||||
<detail>No query provided.</detail>
|
||||
)" },
|
||||
{ /* url */ "/ROOT%23%3F/search?format=xml&pattern=foo",
|
||||
/* HTTP status code */ 400,
|
||||
@@ -1284,7 +1346,7 @@ R"EXPECTEDRESPONSE(const uiLanguages = [
|
||||
{
|
||||
"iso_code": "el",
|
||||
"self_name": "Αγγλικά",
|
||||
"translation_count": 27
|
||||
"translation_count": 23
|
||||
},
|
||||
{
|
||||
"iso_code": "en",
|
||||
@@ -1293,13 +1355,13 @@ R"EXPECTEDRESPONSE(const uiLanguages = [
|
||||
},
|
||||
{
|
||||
"iso_code": "es",
|
||||
"self_name": "Español",
|
||||
"translation_count": 92
|
||||
"self_name": "español",
|
||||
"translation_count": 67
|
||||
},
|
||||
{
|
||||
"iso_code": "fi",
|
||||
"self_name": "suomi",
|
||||
"translation_count": 49
|
||||
"translation_count": 29
|
||||
},
|
||||
{
|
||||
"iso_code": "fr",
|
||||
@@ -1369,12 +1431,12 @@ R"EXPECTEDRESPONSE(const uiLanguages = [
|
||||
{
|
||||
"iso_code": "lb",
|
||||
"self_name": "Lëtzebuergesch",
|
||||
"translation_count": 49
|
||||
"translation_count": 48
|
||||
},
|
||||
{
|
||||
"iso_code": "mk",
|
||||
"self_name": "македонски",
|
||||
"translation_count": 92
|
||||
"translation_count": 81
|
||||
},
|
||||
{
|
||||
"iso_code": "ms",
|
||||
@@ -1389,7 +1451,7 @@ R"EXPECTEDRESPONSE(const uiLanguages = [
|
||||
{
|
||||
"iso_code": "nl",
|
||||
"self_name": "Nederlands",
|
||||
"translation_count": 84
|
||||
"translation_count": 68
|
||||
},
|
||||
{
|
||||
"iso_code": "nqo",
|
||||
@@ -1444,7 +1506,7 @@ R"EXPECTEDRESPONSE(const uiLanguages = [
|
||||
{
|
||||
"iso_code": "sl",
|
||||
"self_name": "slovenščina",
|
||||
"translation_count": 84
|
||||
"translation_count": 57
|
||||
},
|
||||
{
|
||||
"iso_code": "sq",
|
||||
@@ -1454,7 +1516,7 @@ R"EXPECTEDRESPONSE(const uiLanguages = [
|
||||
{
|
||||
"iso_code": "sv",
|
||||
"self_name": "Svenska",
|
||||
"translation_count": 84
|
||||
"translation_count": 67
|
||||
},
|
||||
{
|
||||
"iso_code": "sw",
|
||||
@@ -1474,7 +1536,7 @@ R"EXPECTEDRESPONSE(const uiLanguages = [
|
||||
{
|
||||
"iso_code": "zh-hans",
|
||||
"self_name": "简体中文",
|
||||
"translation_count": 84
|
||||
"translation_count": 68
|
||||
},
|
||||
{
|
||||
"iso_code": "zh-hant",
|
||||
@@ -2301,8 +2363,3 @@ R"(const viewerSettings = {
|
||||
)");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, EmptyPatternSearchDoesNotError)
|
||||
{
|
||||
EXPECT_EQ(200, zfs1_->GET("/ROOT%23%3F/search?content=zimfile")->status);
|
||||
}
|
||||
|
||||
@@ -689,24 +689,6 @@ bool isSubSnippet(std::string subSnippet, const std::string& superSnippet)
|
||||
#define RAYCHARLESZIMID "6f1d19d0-633f-087b-fb55-7ac324ff9baf"
|
||||
#define EXAMPLEZIMID "5dc0b3af-5df2-0925-f0ca-d2bf75e78af6"
|
||||
|
||||
const std::vector<SearchResult> YELLOW_SEARCH_RESULTS = {
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/Eleanor_Rigby",
|
||||
/*title*/ "Eleanor Rigby",
|
||||
/*snippet*/ R"SNIPPET(...-side "<b>Yellow</b> Submarine" (double A-side) Released 5)SNIPPET" "\xC2\xA0" "August" "\xC2\xA0" "1966" "\xC2\xA0" R"SNIPPET((1966-08-05) Format 7-inch single Recorded 28–29 April & 6 June 1966 Studio EMI, London Genre Baroque pop, art rock Length 2:08 Label Parlophone (UK), Capitol (US) Songwriter(s) Lennon–McCartney Producer(s) George Martin The Beatles singles chronology "Paperback Writer" (1966) "Eleanor Rigby" / "<b>Yellow</b> Submarine" (1966) "Strawberry Fields Forever" / "Penny Lane" (1967) Music video "Eleanor Rigby" on YouTube The song continued the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "201"
|
||||
),
|
||||
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/If_You_Go_Away",
|
||||
/*title*/ "If You Go Away",
|
||||
/*snippet*/ R"SNIPPET(...standard and has been recorded by many artists, including Greta Keller, for whom some say McKuen wrote the lyrics. "If You Go Away" Single by Damita Jo from the album If You Go Away B-side "<b>Yellow</b> Days" Released 1966 Genre Jazz Length 3:49 Label Epic Records Songwriter(s) Jacques Brel, Rod McKuen Producer(s) Bob Morgan Damita Jo singles chronology "Gotta Travel On" (1965) "If You Go Away" (1966) "Walk Away" (1967) Damita Jo reached #10 on the Adult Contemporary chart and #68 on the Billboard Hot 100 in 1966 for her version of the song. Terry Jacks recorded a version of the song which was released as a single in 1974 and reached #29 on the Adult Contemporary chart, #68 on the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
)
|
||||
};
|
||||
|
||||
struct TestData
|
||||
{
|
||||
struct PaginationEntry
|
||||
@@ -953,26 +935,6 @@ struct TestData
|
||||
TEST(ServerSearchTest, searchResults)
|
||||
{
|
||||
const TestData testData[] = {
|
||||
{
|
||||
/* query */ "pattern=&books.id=" RAYCHARLESZIMID,
|
||||
/* start */ -1,
|
||||
/* resultsPerPage */ 0,
|
||||
/* totalResultCount */ 0,
|
||||
/* firstResultIndex */ 0,
|
||||
/* results */ {},
|
||||
/* pagination */ {}
|
||||
},
|
||||
|
||||
{
|
||||
/* query */ "pattern=%20&books.id=" RAYCHARLESZIMID,
|
||||
/* start */ -1,
|
||||
/* resultsPerPage */ 0,
|
||||
/* totalResultCount */ 0,
|
||||
/* firstResultIndex */ 0,
|
||||
/* results */ {},
|
||||
/* pagination */ {}
|
||||
},
|
||||
|
||||
{
|
||||
/* query */ "pattern=velomanyunkan&books.id=" RAYCHARLESZIMID,
|
||||
/* start */ -1,
|
||||
@@ -1018,8 +980,24 @@ TEST(ServerSearchTest, searchResults)
|
||||
/* resultsPerPage */ 0,
|
||||
/* totalResultCount */ 2,
|
||||
/* firstResultIndex */ 0,
|
||||
/* results */ YELLOW_SEARCH_RESULTS,
|
||||
/* pagination */ {}
|
||||
/* results */ {
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/Eleanor_Rigby",
|
||||
/*title*/ "Eleanor Rigby",
|
||||
/*snippet*/ R"SNIPPET(...-side "<b>Yellow</b> Submarine" (double A-side) Released 5 August 1966 (1966-08-05) Format 7-inch single Recorded 28–29 April & 6 June 1966 Studio EMI, London Genre Baroque pop, art rock Length 2:08 Label Parlophone (UK), Capitol (US) Songwriter(s) Lennon–McCartney Producer(s) George Martin The Beatles singles chronology "Paperback Writer" (1966) "Eleanor Rigby" / "<b>Yellow</b> Submarine" (1966) "Strawberry Fields Forever" / "Penny Lane" (1967) Music video "Eleanor Rigby" on YouTube The song continued the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "201"
|
||||
),
|
||||
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/If_You_Go_Away",
|
||||
/*title*/ "If You Go Away",
|
||||
/*snippet*/ R"SNIPPET(...standard and has been recorded by many artists, including Greta Keller, for whom some say McKuen wrote the lyrics. "If You Go Away" Single by Damita Jo from the album If You Go Away B-side "<b>Yellow</b> Days" Released 1966 Genre Jazz Length 3:49 Label Epic Records Songwriter(s) Jacques Brel, Rod McKuen Producer(s) Bob Morgan Damita Jo singles chronology "Gotta Travel On" (1965) "If You Go Away" (1966) "Walk Away" (1967) Damita Jo reached #10 on the Adult Contemporary chart and #68 on the Billboard Hot 100 in 1966 for her version of the song. Terry Jacks recorded a version of the song which was released as a single in 1974 and reached #29 on the Adult Contemporary chart, #68 on the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
},
|
||||
|
||||
{
|
||||
@@ -1028,28 +1006,50 @@ TEST(ServerSearchTest, searchResults)
|
||||
/* resultsPerPage */ 0,
|
||||
/* totalResultCount */ 2,
|
||||
/* firstResultIndex */ 0,
|
||||
/* results */ YELLOW_SEARCH_RESULTS,
|
||||
/* pagination */ {}
|
||||
/* results */ {
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/Eleanor_Rigby",
|
||||
/*title*/ "Eleanor Rigby",
|
||||
/*snippet*/ R"SNIPPET(...-side "<b>Yellow</b> Submarine" (double A-side) Released 5 August 1966 (1966-08-05) Format 7-inch single Recorded 28–29 April & 6 June 1966 Studio EMI, London Genre Baroque pop, art rock Length 2:08 Label Parlophone (UK), Capitol (US) Songwriter(s) Lennon–McCartney Producer(s) George Martin The Beatles singles chronology "Paperback Writer" (1966) "Eleanor Rigby" / "<b>Yellow</b> Submarine" (1966) "Strawberry Fields Forever" / "Penny Lane" (1967) Music video "Eleanor Rigby" on YouTube The song continued the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "201"
|
||||
),
|
||||
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/If_You_Go_Away",
|
||||
/*title*/ "If You Go Away",
|
||||
/*snippet*/ R"SNIPPET(...standard and has been recorded by many artists, including Greta Keller, for whom some say McKuen wrote the lyrics. "If You Go Away" Single by Damita Jo from the album If You Go Away B-side "<b>Yellow</b> Days" Released 1966 Genre Jazz Length 3:49 Label Epic Records Songwriter(s) Jacques Brel, Rod McKuen Producer(s) Bob Morgan Damita Jo singles chronology "Gotta Travel On" (1965) "If You Go Away" (1966) "Walk Away" (1967) Damita Jo reached #10 on the Adult Contemporary chart and #68 on the Billboard Hot 100 in 1966 for her version of the song. Terry Jacks recorded a version of the song which was released as a single in 1974 and reached #29 on the Adult Contemporary chart, #68 on the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
},
|
||||
|
||||
{
|
||||
/* query */ "pattern=%20yellow%20&books.id=" RAYCHARLESZIMID,
|
||||
/* query */ "pattern=yellow&books.id=" RAYCHARLESZIMID,
|
||||
/* start */ 0,
|
||||
/* resultsPerPage */ 0,
|
||||
/* totalResultCount */ 2,
|
||||
/* firstResultIndex */ 0,
|
||||
/* results */ YELLOW_SEARCH_RESULTS,
|
||||
/* pagination */ {}
|
||||
},
|
||||
/* results */ {
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/Eleanor_Rigby",
|
||||
/*title*/ "Eleanor Rigby",
|
||||
/*snippet*/ R"SNIPPET(...-side "<b>Yellow</b> Submarine" (double A-side) Released 5 August 1966 (1966-08-05) Format 7-inch single Recorded 28–29 April & 6 June 1966 Studio EMI, London Genre Baroque pop, art rock Length 2:08 Label Parlophone (UK), Capitol (US) Songwriter(s) Lennon–McCartney Producer(s) George Martin The Beatles singles chronology "Paperback Writer" (1966) "Eleanor Rigby" / "<b>Yellow</b> Submarine" (1966) "Strawberry Fields Forever" / "Penny Lane" (1967) Music video "Eleanor Rigby" on YouTube The song continued the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "201"
|
||||
),
|
||||
|
||||
{
|
||||
/* query */ "pattern=yellow%20submarine&books.id=" RAYCHARLESZIMID,
|
||||
/* start */ 0,
|
||||
/* resultsPerPage */ 0,
|
||||
/* totalResultCount */ 1,
|
||||
/* firstResultIndex */ 0,
|
||||
/* results */ { YELLOW_SEARCH_RESULTS[0] },
|
||||
/* pagination */ {}
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT%23%3F/content/zimfile/A/If_You_Go_Away",
|
||||
/*title*/ "If You Go Away",
|
||||
/*snippet*/ R"SNIPPET(...standard and has been recorded by many artists, including Greta Keller, for whom some say McKuen wrote the lyrics. "If You Go Away" Single by Damita Jo from the album If You Go Away B-side "<b>Yellow</b> Days" Released 1966 Genre Jazz Length 3:49 Label Epic Records Songwriter(s) Jacques Brel, Rod McKuen Producer(s) Bob Morgan Damita Jo singles chronology "Gotta Travel On" (1965) "If You Go Away" (1966) "Walk Away" (1967) Damita Jo reached #10 on the Adult Contemporary chart and #68 on the Billboard Hot 100 in 1966 for her version of the song. Terry Jacks recorded a version of the song which was released as a single in 1974 and reached #29 on the Adult Contemporary chart, #68 on the......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -173,8 +173,7 @@ void testSpellingCorrections(const kiwix::SpellingsDB& spellingsDB)
|
||||
EXPECT_SPELLING_CORRECTION("Loremipsum", 1, ({"Lorem ipsum"}));
|
||||
|
||||
// Only one spelling correction can be requested
|
||||
// EXPECT_SPELLING_CORRECTION("Kung", 2, ({"King", "Kong"}));
|
||||
EXPECT_THROW(spellingsDB.getSpellingCorrections("Kung", 2), std::runtime_error);
|
||||
EXPECT_SPELLING_CORRECTION("Kung", 2, ({"King", "Kong"}));
|
||||
}
|
||||
|
||||
using StrCollection = std::vector<std::string>;
|
||||
@@ -190,21 +189,21 @@ StrCollection directoryEntries(std::filesystem::path dirPath)
|
||||
|
||||
TEST_F(SpellingCorrectionTest, allInOne)
|
||||
{
|
||||
const auto tmpDirModTime0 = std::filesystem::last_write_time(tmpDirPath);
|
||||
//const auto tmpDirModTime0 = std::filesystem::last_write_time(tmpDirPath);
|
||||
ASSERT_TRUE(directoryEntries(tmpDirPath).empty());
|
||||
{
|
||||
const kiwix::SpellingsDB spellingsDB(*archive, tmpDirPath);
|
||||
testSpellingCorrections(spellingsDB);
|
||||
}
|
||||
|
||||
const auto tmpDirModTime1 = std::filesystem::last_write_time(tmpDirPath);
|
||||
//const auto tmpDirModTime1 = std::filesystem::last_write_time(tmpDirPath);
|
||||
|
||||
const auto spellingsDbPath = tmpDirPath / "554c9707-897e-097a-53ba-1b1306d8bb88.spellingsdb.v0.1";
|
||||
const auto spellingsDbPath = tmpDirPath / "554c9707-897e-097a-53ba-1b1306d8bb88.spellingsdb.v0.2";
|
||||
|
||||
const StrCollection EXPECTED_DIR_CONTENT{ spellingsDbPath.string() };
|
||||
ASSERT_EQ(directoryEntries(tmpDirPath), EXPECTED_DIR_CONTENT);
|
||||
ASSERT_LT(tmpDirModTime0, tmpDirModTime1);
|
||||
const auto fileModTime = std::filesystem::last_write_time(spellingsDbPath);
|
||||
//ASSERT_LT(tmpDirModTime0, tmpDirModTime1);
|
||||
//const auto fileModTime = std::filesystem::last_write_time(spellingsDbPath);
|
||||
|
||||
{
|
||||
const kiwix::SpellingsDB spellingsDB(*archive, tmpDirPath);
|
||||
@@ -212,6 +211,6 @@ TEST_F(SpellingCorrectionTest, allInOne)
|
||||
}
|
||||
|
||||
ASSERT_EQ(directoryEntries(tmpDirPath), EXPECTED_DIR_CONTENT );
|
||||
ASSERT_EQ(tmpDirModTime1, std::filesystem::last_write_time(tmpDirPath));
|
||||
ASSERT_EQ(fileModTime, std::filesystem::last_write_time(spellingsDbPath));
|
||||
//ASSERT_EQ(tmpDirModTime1, std::filesystem::last_write_time(tmpDirPath));
|
||||
//ASSERT_EQ(fileModTime, std::filesystem::last_write_time(spellingsDbPath));
|
||||
}
|
||||
|
||||
@@ -184,16 +184,4 @@ TEST(stringTools, getSlugifiedFileName)
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(stringTools, Trim)
|
||||
{
|
||||
EXPECT_EQ(kiwix::trim(""), "");
|
||||
EXPECT_EQ(kiwix::trim("abc123"), "abc123");
|
||||
EXPECT_EQ(kiwix::trim(" abc123"), "abc123");
|
||||
EXPECT_EQ(kiwix::trim("abc123 "), "abc123");
|
||||
EXPECT_EQ(kiwix::trim(" abc123 "), "abc123");
|
||||
EXPECT_EQ(kiwix::trim("abc 123"), "abc 123");
|
||||
EXPECT_EQ(kiwix::trim(" "), "");
|
||||
EXPECT_EQ(kiwix::trim("\t abc123 \n"), "abc123");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user