Delete unused file versionparsing.h.
BUG=webrtc:6424 Review-Url: https://codereview.webrtc.org/2373003002 Cr-Commit-Position: refs/heads/master@{#14510}
This commit is contained in:
parent
b20f38792e
commit
2de66fe1c9
@ -407,7 +407,6 @@ if (rtc_include_tests) {
|
||||
"base/timestampaligner_unittest.cc",
|
||||
"base/timeutils_unittest.cc",
|
||||
"base/urlencode_unittest.cc",
|
||||
"base/versionparsing_unittest.cc",
|
||||
"base/weak_ptr_unittest.cc",
|
||||
|
||||
# TODO(ronghuawu): Reenable this test.
|
||||
|
||||
@ -477,8 +477,6 @@ rtc_static_library("rtc_base") {
|
||||
"testclient.h",
|
||||
"transformadapter.cc",
|
||||
"transformadapter.h",
|
||||
"versionparsing.cc",
|
||||
"versionparsing.h",
|
||||
"virtualsocketserver.cc",
|
||||
"virtualsocketserver.h",
|
||||
"window.h",
|
||||
|
||||
@ -438,8 +438,6 @@
|
||||
'testclient.h',
|
||||
'transformadapter.cc',
|
||||
'transformadapter.h',
|
||||
'versionparsing.cc',
|
||||
'versionparsing.h',
|
||||
'virtualsocketserver.cc',
|
||||
'virtualsocketserver.h',
|
||||
'window.h',
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/versionparsing.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
bool ParseVersionString(const std::string& version_str,
|
||||
int num_expected_segments,
|
||||
int version[]) {
|
||||
size_t pos = 0;
|
||||
for (int i = 0;;) {
|
||||
size_t dot_pos = version_str.find('.', pos);
|
||||
size_t n;
|
||||
if (dot_pos == std::string::npos) {
|
||||
// npos here is a special value meaning "to the end of the string"
|
||||
n = std::string::npos;
|
||||
} else {
|
||||
n = dot_pos - pos;
|
||||
}
|
||||
|
||||
version[i] = atoi(version_str.substr(pos, n).c_str());
|
||||
|
||||
if (++i >= num_expected_segments) break;
|
||||
|
||||
if (dot_pos == std::string::npos) {
|
||||
// Previous segment was not terminated by a dot, but there's supposed to
|
||||
// be more segments, so that's an error.
|
||||
return false;
|
||||
}
|
||||
pos = dot_pos + 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int CompareVersions(const int version1[],
|
||||
const int version2[],
|
||||
int num_segments) {
|
||||
for (int i = 0; i < num_segments; ++i) {
|
||||
int diff = version1[i] - version2[i];
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_BASE_VERSIONPARSING_H_
|
||||
#define WEBRTC_BASE_VERSIONPARSING_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
// Parses a version string into an array. "num_expected_segments" must be the
|
||||
// number of numerical segments that the version is expected to have (e.g.,
|
||||
// "1.1.2.0" has 4). "version" must be an array of that length to hold the
|
||||
// parsed numbers.
|
||||
// Returns "true" iff successful.
|
||||
bool ParseVersionString(const std::string& version_str,
|
||||
int num_expected_segments,
|
||||
int version[]);
|
||||
|
||||
// Computes the lexicographical order of two versions. The return value
|
||||
// indicates the order in the standard way (e.g., see strcmp()).
|
||||
int CompareVersions(const int version1[],
|
||||
const int version2[],
|
||||
int num_segments);
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // WEBRTC_BASE_VERSIONPARSING_H_
|
||||
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/versionparsing.h"
|
||||
|
||||
#include "webrtc/base/gunit.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
static const int kExampleSegments = 4;
|
||||
|
||||
typedef int ExampleVersion[kExampleSegments];
|
||||
|
||||
TEST(VersionParsing, TestGoodParse) {
|
||||
ExampleVersion ver;
|
||||
std::string str1("1.1.2.0");
|
||||
static const ExampleVersion expect1 = {1, 1, 2, 0};
|
||||
EXPECT_TRUE(ParseVersionString(str1, kExampleSegments, ver));
|
||||
EXPECT_EQ(0, CompareVersions(ver, expect1, kExampleSegments));
|
||||
std::string str2("2.0.0.1");
|
||||
static const ExampleVersion expect2 = {2, 0, 0, 1};
|
||||
EXPECT_TRUE(ParseVersionString(str2, kExampleSegments, ver));
|
||||
EXPECT_EQ(0, CompareVersions(ver, expect2, kExampleSegments));
|
||||
}
|
||||
|
||||
TEST(VersionParsing, TestBadParse) {
|
||||
ExampleVersion ver;
|
||||
std::string str1("1.1.2");
|
||||
EXPECT_FALSE(ParseVersionString(str1, kExampleSegments, ver));
|
||||
std::string str2("");
|
||||
EXPECT_FALSE(ParseVersionString(str2, kExampleSegments, ver));
|
||||
std::string str3("garbarge");
|
||||
EXPECT_FALSE(ParseVersionString(str3, kExampleSegments, ver));
|
||||
}
|
||||
|
||||
TEST(VersionParsing, TestCompare) {
|
||||
static const ExampleVersion ver1 = {1, 0, 21, 0};
|
||||
static const ExampleVersion ver2 = {1, 1, 2, 0};
|
||||
static const ExampleVersion ver3 = {1, 1, 3, 0};
|
||||
static const ExampleVersion ver4 = {1, 1, 3, 9861};
|
||||
|
||||
// Test that every combination of comparisons has the expected outcome.
|
||||
EXPECT_EQ(0, CompareVersions(ver1, ver1, kExampleSegments));
|
||||
EXPECT_EQ(0, CompareVersions(ver2, ver2, kExampleSegments));
|
||||
EXPECT_EQ(0, CompareVersions(ver3, ver3, kExampleSegments));
|
||||
EXPECT_EQ(0, CompareVersions(ver4, ver4, kExampleSegments));
|
||||
|
||||
EXPECT_GT(0, CompareVersions(ver1, ver2, kExampleSegments));
|
||||
EXPECT_LT(0, CompareVersions(ver2, ver1, kExampleSegments));
|
||||
|
||||
EXPECT_GT(0, CompareVersions(ver1, ver3, kExampleSegments));
|
||||
EXPECT_LT(0, CompareVersions(ver3, ver1, kExampleSegments));
|
||||
|
||||
EXPECT_GT(0, CompareVersions(ver1, ver4, kExampleSegments));
|
||||
EXPECT_LT(0, CompareVersions(ver4, ver1, kExampleSegments));
|
||||
|
||||
EXPECT_GT(0, CompareVersions(ver2, ver3, kExampleSegments));
|
||||
EXPECT_LT(0, CompareVersions(ver3, ver2, kExampleSegments));
|
||||
|
||||
EXPECT_GT(0, CompareVersions(ver2, ver4, kExampleSegments));
|
||||
EXPECT_LT(0, CompareVersions(ver4, ver2, kExampleSegments));
|
||||
|
||||
EXPECT_GT(0, CompareVersions(ver3, ver4, kExampleSegments));
|
||||
EXPECT_LT(0, CompareVersions(ver4, ver3, kExampleSegments));
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
Loading…
x
Reference in New Issue
Block a user