deskflow/src/unittests/base/StringTests.cpp

35 lines
807 B
C++
Raw Normal View History

/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
* SPDX-FileCopyrightText: (C) 2014 - 2021 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#include "StringTests.h"
2025-05-10 03:23:46 +00:00
#include "base/String.h"
void StringTests::formatWithArgs()
{
const char *format = "%%%{1}=%{2}";
const char *arg1 = "answer";
const char *arg2 = "42";
std::string result = deskflow::string::format(format, arg1, arg2);
QCOMPARE(result, "%answer=42");
}
void StringTests::formatedString()
{
const char *format = "%s=%d";
const char *arg1 = "answer";
int arg2 = 42;
std::string result = deskflow::string::sprintf(format, arg1, arg2);
QCOMPARE("answer=42", result);
}
QTEST_MAIN(StringTests)