mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 05:01:25 -07:00
parent
9d90141c29
commit
073ca4267c
17 changed files with 188 additions and 77 deletions
|
@ -26,12 +26,33 @@
|
|||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/utils/string.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
class MyString
|
||||
{
|
||||
public:
|
||||
MyString(const QString &str)
|
||||
: m_str {str}
|
||||
{
|
||||
}
|
||||
|
||||
explicit operator QString() const
|
||||
{
|
||||
return m_str;
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_str;
|
||||
};
|
||||
}
|
||||
|
||||
class TestUtilsString final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -41,6 +62,21 @@ public:
|
|||
TestUtilsString() = default;
|
||||
|
||||
private slots:
|
||||
void testJoinIntoString() const
|
||||
{
|
||||
const QList<QString> list1;
|
||||
QCOMPARE(Utils::String::joinIntoString(list1, u","_s), u""_s);
|
||||
|
||||
const QList<QString> list2 {u"a"_s};
|
||||
QCOMPARE(Utils::String::joinIntoString(list2, u","_s), u"a"_s);
|
||||
|
||||
const QList<QString> list3 {u"a"_s, u"b"_s};
|
||||
QCOMPARE(Utils::String::joinIntoString(list3, u" , "_s), u"a , b"_s);
|
||||
|
||||
const QList<MyString> list4 {u"a"_s, u"b"_s, u"cd"_s};
|
||||
QCOMPARE(Utils::String::joinIntoString(list4, u"++"_s), u"a++b++cd"_s);
|
||||
}
|
||||
|
||||
void testSplitCommand() const
|
||||
{
|
||||
QCOMPARE(Utils::String::splitCommand({}), {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue