VersionTupleTest.cpp
1.52 KB
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
//===- VersionTupleTests.cpp - Version Number Handling Tests --------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/VersionTuple.h"
#include "gtest/gtest.h"
using namespace llvm;
TEST(VersionTuple, getAsString) {
EXPECT_EQ("0", VersionTuple().getAsString());
EXPECT_EQ("1", VersionTuple(1).getAsString());
EXPECT_EQ("1.2", VersionTuple(1, 2).getAsString());
EXPECT_EQ("1.2.3", VersionTuple(1, 2, 3).getAsString());
EXPECT_EQ("1.2.3.4", VersionTuple(1, 2, 3, 4).getAsString());
}
TEST(VersionTuple, tryParse) {
VersionTuple VT;
EXPECT_FALSE(VT.tryParse("1"));
EXPECT_EQ("1", VT.getAsString());
EXPECT_FALSE(VT.tryParse("1.2"));
EXPECT_EQ("1.2", VT.getAsString());
EXPECT_FALSE(VT.tryParse("1.2.3"));
EXPECT_EQ("1.2.3", VT.getAsString());
EXPECT_FALSE(VT.tryParse("1.2.3.4"));
EXPECT_EQ("1.2.3.4", VT.getAsString());
EXPECT_TRUE(VT.tryParse(""));
EXPECT_TRUE(VT.tryParse("1."));
EXPECT_TRUE(VT.tryParse("1.2."));
EXPECT_TRUE(VT.tryParse("1.2.3."));
EXPECT_TRUE(VT.tryParse("1.2.3.4."));
EXPECT_TRUE(VT.tryParse("1.2.3.4.5"));
EXPECT_TRUE(VT.tryParse("1-2"));
EXPECT_TRUE(VT.tryParse("1+2"));
EXPECT_TRUE(VT.tryParse(".1"));
EXPECT_TRUE(VT.tryParse(" 1"));
EXPECT_TRUE(VT.tryParse("1 "));
EXPECT_TRUE(VT.tryParse("."));
}