From 2de66fe1c96eb719c1f38506bcc9f0c398bb6f62 Mon Sep 17 00:00:00 2001 From: nisse Date: Tue, 4 Oct 2016 23:24:57 -0700 Subject: [PATCH] Delete unused file versionparsing.h. BUG=webrtc:6424 Review-Url: https://codereview.webrtc.org/2373003002 Cr-Commit-Position: refs/heads/master@{#14510} --- webrtc/BUILD.gn | 1 - webrtc/base/BUILD.gn | 2 - webrtc/base/base.gyp | 2 - webrtc/base/versionparsing.cc | 57 -------------------- webrtc/base/versionparsing.h | 35 ------------ webrtc/base/versionparsing_unittest.cc | 74 -------------------------- 6 files changed, 171 deletions(-) delete mode 100644 webrtc/base/versionparsing.cc delete mode 100644 webrtc/base/versionparsing.h delete mode 100644 webrtc/base/versionparsing_unittest.cc diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index 690344a631..e241a57176 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -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. diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index cc451e83eb..e830cd5388 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -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", diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp index 4dc1d08dae..b09cccf6f1 100644 --- a/webrtc/base/base.gyp +++ b/webrtc/base/base.gyp @@ -438,8 +438,6 @@ 'testclient.h', 'transformadapter.cc', 'transformadapter.h', - 'versionparsing.cc', - 'versionparsing.h', 'virtualsocketserver.cc', 'virtualsocketserver.h', 'window.h', diff --git a/webrtc/base/versionparsing.cc b/webrtc/base/versionparsing.cc deleted file mode 100644 index c3f982ff6e..0000000000 --- a/webrtc/base/versionparsing.cc +++ /dev/null @@ -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 - -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 diff --git a/webrtc/base/versionparsing.h b/webrtc/base/versionparsing.h deleted file mode 100644 index be2d332381..0000000000 --- a/webrtc/base/versionparsing.h +++ /dev/null @@ -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 - -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_ diff --git a/webrtc/base/versionparsing_unittest.cc b/webrtc/base/versionparsing_unittest.cc deleted file mode 100644 index 51156991a6..0000000000 --- a/webrtc/base/versionparsing_unittest.cc +++ /dev/null @@ -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