File indexing completed on 2024-04-21 05:48:29

0001 /***********************************************************************
0002  * SPDX-FileCopyrightText: 2020 Shubham <aryan100jangid@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  ***********************************************************************/
0006 
0007 #include "testFileTree.h"
0008 
0009 TestFileTree::TestFileTree()
0010     : m_file(std::make_unique<File>(qUtf8Printable(QFINDTESTDATA("dummy.txt")), 20))
0011 {
0012 }
0013 
0014 void TestFileTree::testFileName()
0015 {
0016     const QString fname = m_file->displayName();
0017     QCOMPARE(QFINDTESTDATA("dummy.txt"), fname);
0018 }
0019 
0020 void TestFileTree::testFileSize()
0021 {
0022     const quint64 fsize = m_file->size();
0023     QVERIFY(fsize > 0);
0024 }
0025 
0026 void TestFileTree::testFilePath()
0027 {
0028     auto folder = std::make_shared<Folder>("./autotests/core/");
0029     const QString fpath = m_file->displayPath(folder);
0030     QVERIFY(!fpath.isEmpty());
0031 }
0032 
0033 void TestFileTree::testDuplicate()
0034 {
0035     auto foo = std::make_shared<Folder>("foo/");
0036     auto bar = std::make_shared<Folder>("bar/");
0037     auto file = std::make_shared<Folder>("file/");
0038     auto light = std::make_shared<Folder>("light/");
0039     bar->append("onion", 1024);
0040     light->append("torch", 128);
0041     file->append(light);
0042     foo->append(bar);
0043     foo->append(file);
0044     foo->append("shallot", 512);
0045     auto other = foo->duplicate();
0046     qDebug() << other->size();
0047     QCOMPARE(other->size(), foo->size());
0048     QCOMPARE(other->children(), foo->children());
0049 }
0050 
0051 QTEST_MAIN(TestFileTree)