"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xbmc/utils/test/TestStringUtils.cpp" between
xbmc-18.7.1-Leia.tar.gz and xbmc-18.8-Leia.tar.gz

About: XBMC is a software media player and entertainment hub for digital media that plays almost all popular audio and video formats around (new name "Kodi").

TestStringUtils.cpp  (xbmc-18.7.1-Leia):TestStringUtils.cpp  (xbmc-18.8-Leia)
skipping to change at line 14 skipping to change at line 14
* *
* SPDX-License-Identifier: GPL-2.0-or-later * SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information. * See LICENSES/README.md for more information.
*/ */
#include "utils/StringUtils.h" #include "utils/StringUtils.h"
#include <algorithm> #include <algorithm>
#include "gtest/gtest.h" #include "gtest/gtest.h"
enum class ECG
{
A,
B
};
enum EG
{
C,
D
};
namespace test_enum
{
enum class ECN
{
A = 1,
B
};
enum EN
{
C = 1,
D
};
}
TEST(TestStringUtils, Format) TEST(TestStringUtils, Format)
{ {
std::string refstr = "test 25 2.7 ff FF"; std::string refstr = "test 25 2.7 ff FF";
std::string varstr = StringUtils::Format("%s %d %.1f %x %02X", "test", 25, 2.7 43f, 0x00ff, 0x00ff); std::string varstr = StringUtils::Format("%s %d %.1f %x %02X", "test", 25, 2.7 43f, 0x00ff, 0x00ff);
EXPECT_STREQ(refstr.c_str(), varstr.c_str()); EXPECT_STREQ(refstr.c_str(), varstr.c_str());
varstr = StringUtils::Format("", "test", 25, 2.743f, 0x00ff, 0x00ff); varstr = StringUtils::Format("", "test", 25, 2.743f, 0x00ff, 0x00ff);
EXPECT_STREQ("", varstr.c_str()); EXPECT_STREQ("", varstr.c_str());
} }
TEST(TestStringUtils, FormatEnum)
{
const char* zero = "0";
const char* one = "1";
std::string varstr = StringUtils::Format("{}", ECG::A);
EXPECT_STREQ(zero, varstr.c_str());
varstr = StringUtils::Format("{}", EG::C);
EXPECT_STREQ(zero, varstr.c_str());
varstr = StringUtils::Format("{}", test_enum::ECN::A);
EXPECT_STREQ(one, varstr.c_str());
varstr = StringUtils::Format("{}", test_enum::EN::C);
EXPECT_STREQ(one, varstr.c_str());
}
TEST(TestStringUtils, FormatEnumWidth)
{
const char* one = "01";
std::string varstr = StringUtils::Format("{:02d}", ECG::B);
EXPECT_STREQ(one, varstr.c_str());
varstr = StringUtils::Format("%02d", EG::D);
EXPECT_STREQ(one, varstr.c_str());
}
TEST(TestStringUtils, ToUpper) TEST(TestStringUtils, ToUpper)
{ {
std::string refstr = "TEST"; std::string refstr = "TEST";
std::string varstr = "TeSt"; std::string varstr = "TeSt";
StringUtils::ToUpper(varstr); StringUtils::ToUpper(varstr);
EXPECT_STREQ(refstr.c_str(), varstr.c_str()); EXPECT_STREQ(refstr.c_str(), varstr.c_str());
} }
TEST(TestStringUtils, ToLower) TEST(TestStringUtils, ToLower)
 End of changes. 2 change blocks. 
0 lines changed or deleted 55 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)