forked from easz/cpp-semver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_valid.cpp
53 lines (48 loc) · 891 Bytes
/
test_valid.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 <vector>
#include <string>
const std::vector<std::string> is_not_valid
{
"a.b.c",
"x0.0.1",
"-1",
"1.2.3.4",
">= 1.2",
">=1.2.",
"|| blah || ",
" 1.0.0 -- *.0.0 ",
"1-2 || 2-3",
"1-22-3",
">2 <1",
"1.2.3-pre...",
"1.2.3-pre.01",
"1.2.3-pre.1-",
"1.2-pre",
"1.2.3-",
"1.2.3+",
};
const std::vector<std::string> is_valid
{
"v0.0.1",
"=1",
">=1.2",
"1 - 2 || 2 - 3",
"1.2.3-pre.----.0.10",
"1.2.3-pre.10",
"1.2.3-pre.0",
"1.2.3-pre.-010",
};
void run_test()
{
for (const std::string& input : is_valid)
{
std::cout << "[Test] valid(\"" << input << "\")" << std::endl;
TEST_ASSERT(semver::valid(input));
}
for (const std::string& input : is_not_valid)
{
std::cout << "[Test] !valid(\"" << input << "\")" << std::endl;
TEST_ASSERT(!semver::valid(input));
}
}