File indexing completed on 2024-10-13 04:24:28
0001 /* 0002 SPDX-FileCopyrightText: 2023 Julius Künzel <jk.kdedev@smartlab.uber.space> 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #include "catch.hpp" 0007 #include "test_utils.hpp" 0008 // test specific headers 0009 #include "utils/qstringutils.h" 0010 0011 TEST_CASE("Testing for different utils", "[Utils]") 0012 { 0013 0014 SECTION("Append to filename") 0015 { 0016 QString filename("myfile.mp4"); 0017 QString appendix("-hello"); 0018 QString newName = QStringUtils::appendToFilename(filename, appendix); 0019 qDebug() << newName; 0020 REQUIRE(newName == QStringLiteral("myfile-hello.mp4")); 0021 } 0022 0023 SECTION("Unique names should really be unique") 0024 { 0025 QStringList names; 0026 for (int i = 0; i < 1000; i++) { 0027 names << QStringUtils::getUniqueName(names, QStringLiteral("my923test.string-1")); 0028 } 0029 0030 REQUIRE(names.removeDuplicates() == 0); 0031 } 0032 }