51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
|
|
#include "../version.hpp"
|
|
#include "../debug.hpp"
|
|
|
|
|
|
struct parsed_version {
|
|
string str;
|
|
vector <unsigned int> parts;
|
|
};
|
|
|
|
|
|
int
|
|
main (int, char **) {
|
|
vector <parsed_version> tests ({
|
|
{ "1", { 1 } },
|
|
|
|
{ "1.2", { 1, 2 } },
|
|
{ "1.2.3", { 1, 2, 3 } },
|
|
{ "1.2.3.4", { 1, 2, 3, 4 } },
|
|
|
|
{ "9.5a", { 9, 5 } },
|
|
{ "8.2.5b", { 8, 2, 5 } },
|
|
|
|
/*
|
|
{ "1.4.1-p8", { 1, 4, 1 } },
|
|
{ "4.2.0-r4", { 4, 2, 0 } },
|
|
|
|
{ "1.4 RC1", { 1, 4 } }
|
|
*/
|
|
});
|
|
|
|
for (auto i = tests.begin (); i != tests.end (); ++i) {
|
|
version v (i->str);
|
|
|
|
if (i->parts.size () > 0) check (v.major () == i->parts[0]);
|
|
if (i->parts.size () > 1) check (v.minor () == i->parts[1]);
|
|
if (i->parts.size () > 2) check (v.point () == i->parts[2]);
|
|
if (i->parts.size () > 3) check (v.build () == i->parts[3]);
|
|
|
|
check_hard (i->parts.size () <= 4);
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|