added test for ModDescription class
This commit is contained in:
parent
4fcfd6787d
commit
7fac9bd6e2
@ -35,12 +35,12 @@ int ModDescription::getReleaseNr() {
|
||||
}
|
||||
|
||||
std::string ModDescription::getNextDependency() {
|
||||
if(_depsIterator + 2 < _deps.size()) {
|
||||
if(_depsIterator + 1 < _deps.size()) {
|
||||
_depsIterator++;
|
||||
return _deps[_depsIterator];
|
||||
} else {
|
||||
_depsAtEnd = true;
|
||||
return "getNextDependency failed...";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,10 +79,13 @@ void ModDescription::setRepositoryAddress(std::string repoaddr) {
|
||||
_repoaddr = repoaddr;
|
||||
}
|
||||
|
||||
void resetDependencyIterator() {
|
||||
void ModDescription::resetDependencyIterator() {
|
||||
_depsIterator = -1;
|
||||
if(_depsAtEnd == true) {
|
||||
_depsAtEnd = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool dependenciesEnd() {
|
||||
bool ModDescription::dependenciesEnd() {
|
||||
return _depsAtEnd;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
/// \namespace mmm
|
||||
/// \brief A global namespace for 3m
|
||||
namespace mmm }
|
||||
namespace mmm {
|
||||
/// \class ModDescription
|
||||
/// \brief A class describing a mod.
|
||||
class ModDescription {
|
||||
@ -30,7 +30,7 @@ public:
|
||||
///< \return Mod name.
|
||||
std::string getDescription(); ///< \brief A function returning mod description.
|
||||
///< \return Mod description.
|
||||
std::string getReleaseNr(); ///< \brief A function returning 3m package release number.
|
||||
int getReleaseNr(); ///< \brief A function returning 3m package release number.
|
||||
///< \return 3m package release number.
|
||||
std::string getNextDependency(); ///< \brief A function returning next dependency from the dependency list.
|
||||
///< \return Next dependency from the dependency list.
|
||||
|
2
OBJECTS
2
OBJECTS
@ -1,5 +1,5 @@
|
||||
ModDescription: name, description, release, deps, repotype, repoaddr
|
||||
ModList: name, vector<ModDescription>
|
||||
ModList: ModListDescription, vector<ModDescription>
|
||||
LocalModDescription: ModDescription + remoteModlist (inheritance)
|
||||
LocalModList: vector<LocalModDescription>
|
||||
RepositoryModDescription: ModDescription + path (inheritance)
|
||||
|
BIN
filetesters/configparser
Executable file
BIN
filetesters/configparser
Executable file
Binary file not shown.
BIN
filetesters/modinfoparser
Executable file
BIN
filetesters/modinfoparser
Executable file
Binary file not shown.
BIN
filetesters/modlistparser
Executable file
BIN
filetesters/modlistparser
Executable file
Binary file not shown.
@ -1,7 +1,9 @@
|
||||
CXXFLAGS=-Wall
|
||||
all:
|
||||
${CXX} ${CXXFLAGS} -o ConfigFileTest ConfigFileTest.cpp ../ConfigFile.cpp ../3mExceptions.cpp
|
||||
${CXX} ${CXXFLAGS} -o ModDescriptionTest ModDescriptionTest.cpp ../ModDescription.cpp
|
||||
debug:
|
||||
${CXX} ${CXXFLAGS} -o ConfigFileTest ConfigFileTest.cpp ../ConfigFile.cpp ../3mExceptions.cpp -g
|
||||
${CXX} ${CXXFLAGS} -o ModDescriptionTest ModDescriptionTest.cpp ../ModDescription.cpp -g
|
||||
clean:
|
||||
rm -rf ConfigFileTest
|
||||
rm -rf ConfigFileTest ModDescriptionTest
|
||||
|
26
tests/ModDescriptionTest.cpp
Normal file
26
tests/ModDescriptionTest.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include "../ModDescription.h"
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
mmm::ModDescription md;
|
||||
md.setName("test");
|
||||
md.setDescription("Test ModDescription entry");
|
||||
md.setReleaseNr(1);
|
||||
md.setRepositoryType("archive");
|
||||
md.setRepositoryAddress("http://example.tld/mod.zip");
|
||||
md.insertDependency("test2");
|
||||
md.insertDependency("test3");
|
||||
cout << "Name: " << md.getName() << endl << "Description: " << md.getDescription() << endl << "Release number: " << md.getReleaseNr() << endl << "Depends on: ";
|
||||
while(!md.dependenciesEnd()) {
|
||||
cout << md.getNextDependency() << " ";
|
||||
}
|
||||
cout << endl << "Dependencies again: ";
|
||||
md.resetDependencyIterator();
|
||||
while(!md.dependenciesEnd()) {
|
||||
cout << md.getNextDependency() << " ";
|
||||
}
|
||||
cout << endl << "Repository type: " << md.getRepositoryType() << endl << "Repository address: " << md.getRepositoryAddress() << endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user