blob: b3f84eb901aa512fd40a2720ed80be3da780b07a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "test/TestUtils.h"
#include "utils/StringUtils.h"
#include "utils/XBMCTinyXML.h"
#include <gtest/gtest.h>
TEST(TestXBMCTinyXML, ParseFromString)
{
bool retval = false;
// scraper results with unescaped &
CXBMCTinyXML doc;
std::string data("<details><url function=\"ParseTMDBRating\" "
"cache=\"tmdb-en-12244.json\">"
"http://api.themoviedb.org/3/movie/12244"
"?api_key=57983e31fb435df4df77afb854740ea9"
"&language=en???</url></details>");
doc.Parse(data);
TiXmlNode *root = doc.RootElement();
if (root && root->ValueStr() == "details")
{
TiXmlElement *url = root->FirstChildElement("url");
if (url && url->FirstChild())
{
retval = (url->FirstChild()->ValueStr() == "http://api.themoviedb.org/3/movie/12244?api_key=57983e31fb435df4df77afb854740ea9&language=en???");
}
}
EXPECT_TRUE(retval);
}
TEST(TestXBMCTinyXML, ParseFromFileHandle)
{
bool retval = false;
// scraper results with unescaped &
CXBMCTinyXML doc;
FILE *f = fopen(XBMC_REF_FILE_PATH("/xbmc/utils/test/CXBMCTinyXML-test.xml").c_str(), "r");
ASSERT_NE(nullptr, f);
doc.LoadFile(f);
fclose(f);
TiXmlNode *root = doc.RootElement();
if (root && root->ValueStr() == "details")
{
TiXmlElement *url = root->FirstChildElement("url");
if (url && url->FirstChild())
{
std::string str = url->FirstChild()->ValueStr();
retval = (StringUtils::Trim(str) == "http://api.themoviedb.org/3/movie/12244?api_key=57983e31fb435df4df77afb854740ea9&language=en???");
}
}
EXPECT_TRUE(retval);
}
|