mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
27368e7e22
Summary: This kind of functionality is useful to other project apart from clang. LLDB works with version numbers a lot, but it does not have a convenient abstraction for this. Moving this class to a lower level library allows it to be freely used within LLDB. Since this class is used in a lot of places in clang, and it used to be in the clang namespace, it seemed appropriate to add it to the list of adopted classes in LLVM.h to avoid prefixing all uses with "llvm::". Also, I didn't find any tests specific for this class, so I wrote a couple of quick ones for the more interesting bits of functionality. Reviewers: zturner, erik.pilkington Subscribers: mgorny, cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D47887 llvm-svn: 334399
51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
//===- VersionTupleTests.cpp - Version Number Handling Tests --------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#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("."));
|
|
}
|