From 1a8d874a2c8f22ee78b648fddfa41b3e796f6212 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sun, 15 May 2022 23:46:13 +0400 Subject: [PATCH] Testing the request for an out-of-bounds page --- test/server.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/server.cpp b/test/server.cpp index 774e19204..74c0b8b70 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -1645,7 +1645,7 @@ TEST_F(TaskbarlessServerTest, searchResults) )"; - const size_t lastResultIndex = firstResultIndex + results.size() - 1; + const size_t lastResultIndex = std::min(totalResultCount, firstResultIndex + results.size() - 1); header = replace(header, "FIRSTRESULT", to_string(firstResultIndex)); header = replace(header, "LASTRESULT", to_string(lastResultIndex)); header = replace(header, "RESULTCOUNT", to_string(totalResultCount)); @@ -2073,6 +2073,26 @@ R"SEARCHRESULT( { "▶", 40, false }, } }, + + // This test-point only documents how the current implementation + // works, not how it should work! + { + /* pattern */ "jazz", + /* start */ 45, + /* resultsPerPage */ 5, + /* totalResultCount */ 44, + /* firstResultIndex */ 46, + /* results */ {}, + + /* pagination */ { + { "◀", 0, false }, + { "6", 25, false }, + { "7", 30, false }, + { "8", 35, false }, + { "9", 40, false }, + { "▶", 40, false }, + } + }, }; for ( const auto& t : testData ) {