Advertisement
cepxuozab

CompareSearchCase8

Mar 30th, 2023
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. void PrintDocumentUTest(const Document& document) {
  2.     std::cout << "{ "
  3.               << "document_id = " << document.id << ", "
  4.               << "relevance = " << document.relevance << ", "
  5.               << "rating = " << document.rating << " }" << std::endl;
  6. }
  7. void TestDoubleComparison() {
  8. const std::vector<int> ratings1 = {1, 2, 3, 4, 5};
  9. const std::vector<int> ratings2 = {-1, -2, 30, -3, 44, 5};
  10. const std::vector<int> ratings3 = {12, -20, 80, 0, 8, 0, 0, 9, 67};
  11.     std::string stop_words = "и в на";
  12.     SearchServer search_server(stop_words);
  13.  
  14.     search_server.AddDocument(0, "белый кот и модный ошейник", DocumentStatus::ACTUAL, ratings1);
  15.     search_server.AddDocument(1, "пушистый хвост кот", DocumentStatus::ACTUAL, ratings2);
  16.     search_server.AddDocument(2, "пушистый кот хвост", DocumentStatus::ACTUAL, ratings3);
  17.  
  18.     const std::string query = "пушистый кот пушистый хвост";
  19.     const auto documents = search_server.FindTopDocuments(query);
  20.  
  21.     std::cout << "Top documents for query:" << std::endl;
  22.     for (const Document& document : documents) {
  23.         PrintDocumentUTest(document);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement