Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/RopeByteStringSubstringTest.java

Issue 2599263002: third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/RopeByteStringSubstringTest.java
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestCornerCases.cs b/third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/RopeByteStringSubstringTest.java
similarity index 60%
copy from third_party/protobuf/csharp/src/Google.Protobuf.Test/TestCornerCases.cs
copy to third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/RopeByteStringSubstringTest.java
index fd75b19f42ed9de79a1d373a12038dcf0a103fef..3c1f5035b71ba648eb5c4a21d747631ac7504b82 100644
--- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/TestCornerCases.cs
+++ b/third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/RopeByteStringSubstringTest.java
@@ -1,7 +1,6 @@
-#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
+// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -28,35 +27,36 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using UnitTest.Issues.TestProtos;
-using NUnit.Framework;
-namespace Google.Protobuf
-{
- public class TestCornerCases
- {
- [Test]
- public void TestRoundTripNegativeEnums()
- {
- NegativeEnumMessage msg = new NegativeEnumMessage
- {
- Value = NegativeEnum.MinusOne,
- Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow },
- PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }
- };
+package com.google.protobuf.test;
+import com.google.protobuf.*;
- Assert.AreEqual(58, msg.CalculateSize());
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
- byte[] bytes = new byte[58];
- CodedOutputStream output = new CodedOutputStream(bytes);
+/**
+ * This class tests {@link RopeByteString#substring(int, int)} by inheriting the tests from
+ * {@link LiteralByteStringTest}. Only a couple of methods are overridden.
+ *
+ * @author carlanton@google.com (Carl Haverl)
+ */
+public class RopeByteStringSubstringTest extends LiteralByteStringTest {
- msg.WriteTo(output);
- Assert.AreEqual(0, output.SpaceLeft);
-
- NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes);
- Assert.AreEqual(msg, copy);
- }
+ @Override
+ protected void setUp() throws Exception {
+ classUnderTest = "RopeByteString";
+ byte[] sourceBytes = ByteStringTest.getTestBytes(22341, 22337766L);
+ Iterator<ByteString> iter = ByteStringTest.makeConcretePieces(sourceBytes).iterator();
+ ByteString sourceString = iter.next();
+ while (iter.hasNext()) {
+ sourceString = sourceString.concat(iter.next());
}
+
+ int from = 1130;
+ int to = sourceBytes.length - 5555;
+ stringUnderTest = sourceString.substring(from, to);
+ referenceBytes = new byte[to - from];
+ System.arraycopy(sourceBytes, from, referenceBytes, 0, to - from);
+ expectedHashCode = -1259260680;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698