1/*
2 * This file is part of nzbget. See <https://nzbget.com>.
3 *
4 * Copyright (C) 2015-2016 Andrey Prygunkov <hugbug@users.sourceforge.net>
5 * Copyright (C) 2024 Denis <denis@nzbget.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21
22#include "nzbget.h"
23
24#include <boost/test/unit_test.hpp>
25#include "FileSystem.h"
26#include "DupeMatcher.h"
27#include "TestUtil.h"
28
29BOOST_AUTO_TEST_CASE(DupeMatcherTest)
30{
31 const std::string testDataDir = TestUtil::WorkingDir() + "/rarrenamer";
32 const std::string workingDir = testDataDir + "/DupeMatcher";
33 FileSystem::CreateDirectory(workingDir.c_str());
34
35 CString errmsg;
36
37 // prepare directories
38
39 std::string dupe1(workingDir + "/dupe1");
40 BOOST_CHECK(FileSystem::ForceDirectories(dupe1.c_str(), errmsg));
41 FileSystem::CopyFile(dupe1.c_str(), (testDataDir + "/parchecker").c_str());
42
43 std::string dupe2(workingDir + "/dupe2");
44 BOOST_CHECK(FileSystem::ForceDirectories(dupe2.c_str(), errmsg));
45 FileSystem::CopyFile(dupe2.c_str(), (testDataDir + "/parchecker").c_str());
46 FileSystem::DeleteFile((dupe2 + "/testfile.nfo").c_str());
47
48 std::string rardupe1(testDataDir + "/dupematcher1");
49 std::string rardupe2(testDataDir + "/dupematcher2");
50
51 std::string nondupe(workingDir + "/nondupe");
52 BOOST_CHECK(FileSystem::ForceDirectories(nondupe.c_str(), errmsg));
53 FileSystem::CopyFile(nondupe.c_str(), (testDataDir + "/parchecker").c_str());
54 remove((nondupe + "/testfile.dat").c_str());
55
56 // now test
57 int64 expectedSize = FileSystem::FileSize((dupe1 + "/testfile.dat").c_str());
58
59 BOOST_TEST_MESSAGE("This test requires working unrar 5 in search path");
…lines 60–96 unchanged (37 lines)