/* * Copyright (C) 2023 Nikhil Tanwar (2002nikhiltanwar@gmail.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "gtest/gtest.h" #include "../include/tools.h" typedef kiwix::FeedLanguages FeedLanguages; typedef kiwix::FeedCategories FeedCategories; namespace { const char sampleLanguageOpdsStream[] = R"( 1e587935-0f7b-dad6-eddc-ef3fafd4c3ed List of languages 2023-07-11T15:35:09Z Abkhazian abk 3 2023-07-11T15:35:09Z 2e4d9a1c-9750-0418-8124-a0c663e206f7 isiZulu zul 4 2023-07-11T15:35:09Z 76eec223-994d-9b95-e309-baee06e585b0 )"; const char sampleCategoriesOpdsStream[] = R"( 231da20c-0fe0-7345-11b2-d29f50364108 List of categories 2023-07-11T15:35:09Z gutenberg 2023-07-11T15:35:09Z 401dbe68-2f7a-5503-b431-054801c30bab All entries with category of 'gutenberg'. iFixit 2023-07-11T15:35:09Z c18e5459-af23-5fbf-0622-ff271bd9a5ad All entries with category of 'iFixit'. wikivoyage 2023-07-11T15:35:09Z 9a75be6c-7a35-6f52-1a69-bee9ad248459 All entries with category of 'wikivoyage'. wiktionary 2023-07-11T15:35:09Z 7adb9f1a-73d7-0391-1238-d2e2c300ddaa All entries with category of 'wiktionary'. )"; TEST(OpdsParsingTest, languageTest) { FeedLanguages expectedLanguagesFromFeed = {{"abk", "Abkhazian"}, {"zul", "isiZulu"}}; EXPECT_EQ(kiwix::readLanguagesFromFeed(sampleLanguageOpdsStream), expectedLanguagesFromFeed); } TEST(OpdsParsingTest, categoryTest) { FeedCategories expectedCategoriesFromFeed = {"gutenberg", "iFixit", "wikivoyage", "wiktionary"}; EXPECT_EQ(kiwix::readCategoriesFromFeed(sampleCategoriesOpdsStream), expectedCategoriesFromFeed); } }