forked from easz/cpp-semver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_simple_part.cpp
53 lines (41 loc) · 1.42 KB
/
test_simple_part.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "test.hpp"
#include "cpp-semver.hpp"
#include <tuple>
#include <vector>
#include <string>
#define TUPL std::make_tuple
#define VECS std::vector<std::string>
const std::vector< std::tuple<
std::string,/* input */
int,/* major */
int,/* minor */
int,/* patch */
std::vector<std::string>/* pre*/ > > test_data
{
TUPL( "1.2.3-pre.4.5.6", 1, 2, 3, VECS{ "pre", "4", "5", "6" } ),
TUPL( "1.2.3-pre.40.50.60+build--", 1, 2, 3, VECS{ "pre", "40", "50", "60" } ),
TUPL( "1.2.3", 1, 2, 3, VECS{} ),
TUPL( "1.2", 1, 2, 0, VECS{} )
};
void run_test()
{
for (const auto& tpl : test_data)
{
const auto& input = std::get<0>(tpl);
const auto& major = std::get<1>(tpl);
const auto& minor = std::get<2>(tpl);
const auto& patch = std::get<3>(tpl);
const auto& pre = std::get<4>(tpl);
std::cout << "[Test] major(\"" << input << "\")" << std::endl;
TEST_ASSERT(major == semver::major(input));
std::cout << "[Test] minor(\"" << input << "\")" << std::endl;
TEST_ASSERT(minor == semver::minor(input));
std::cout << "[Test] patch(\"" << input << "\")" << std::endl;
TEST_ASSERT(patch == semver::patch(input));
std::cout << "[Test] prerelease(\"" << input << "\")" << std::endl;
const auto prerelease = semver::prerelease(input);
TEST_ASSERT(pre.size() == prerelease.size());
for (size_t i = 0; i < pre.size(); i++)
TEST_ASSERT(pre.at(i) == prerelease.at(i));
}
}