testmodreader.cpp
1 //------------------------------------------------------------------------------
2 // testmodreader.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2019 Pol Marcet Sardà <polmarcetsarda@gmail.com>
22 //------------------------------------------------------------------------------
23 
24 #include "testmodreader.h"
25 
26 #include "modreader.h"
27 
28 #include <QResource>
29 #include <QSet>
30 #include <QSharedPointer>
31 
32 bool TestModReader::executeTest()
33 {
34  // If something fails, set to false;
35  bool result = true;
36 
37  // Map searching
38  QSet<QString> mapsToCheck =
39  {
40  "pk3map", // PK3 format
41  "BASEPK3", // PK3 format, those can have wads on their base-directory.
42  "HEXENMAP", // Hexen format
43  "DOOMMAP", // Doom format
44  "UDMFMAP" // Udmf format
45  };
46  QSharedPointer<ModReader> modReader(ModReader::create(QResource("7zedWadsTest.7z").absoluteFilePath()));
47  if (!modReader.isNull())
48  {
49  modReader->load();
50  QStringList maps = modReader->getAllMaps();
51  for (const QString &map : mapsToCheck)
52  {
53  bool found = maps.contains(map);
54  testLog << map + " - " + ((found) ? "Found" : "Not Found");
55  if (!found)
56  result = false;
57  }
58  }
59  else
60  result = false;
61 
62  return result;
63 }