/*
* 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-ef3fafd4c3edList of languages2023-07-11T15:35:09ZAbkhazianabk32023-07-11T15:35:09Z2e4d9a1c-9750-0418-8124-a0c663e206f7isiZuluzul42023-07-11T15:35:09Z76eec223-994d-9b95-e309-baee06e585b0
)";
const char sampleCategoriesOpdsStream[] = R"(
231da20c-0fe0-7345-11b2-d29f50364108List of categories2023-07-11T15:35:09Zgutenberg2023-07-11T15:35:09Z401dbe68-2f7a-5503-b431-054801c30babAll entries with category of 'gutenberg'.iFixit2023-07-11T15:35:09Zc18e5459-af23-5fbf-0622-ff271bd9a5adAll entries with category of 'iFixit'.wikivoyage2023-07-11T15:35:09Z9a75be6c-7a35-6f52-1a69-bee9ad248459All entries with category of 'wikivoyage'.wiktionary2023-07-11T15:35:09Z7adb9f1a-73d7-0391-1238-d2e2c300ddaaAll 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);
}
}