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

Unified Diff: third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: owners Created 4 years, 7 months 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/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java
diff --git a/third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java
similarity index 50%
rename from third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
rename to third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java
index e7905f79d05a2f7760dd1e99c93b317bbb89382d..c42bfa6e71aefb9037321f49bb2b77fd46e6cebc 100644
--- a/third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
+++ b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java
@@ -30,51 +30,57 @@
package com.google.protobuf;
-import protobuf_unittest.UnittestProto.TestDeprecatedFields;
-
import junit.framework.TestCase;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
/**
- * Test field deprecation
- *
- * @author birdo@google.com (Roberto Scaramuzzi)
+ * Test @{link TextFormatParseLocation}.
*/
-public class DeprecatedFieldTest extends TestCase {
- private String[] deprecatedGetterNames = {
- "hasDeprecatedInt32",
- "getDeprecatedInt32"};
-
- private String[] deprecatedBuilderGetterNames = {
- "hasDeprecatedInt32",
- "getDeprecatedInt32",
- "clearDeprecatedInt32"};
-
- private String[] deprecatedBuilderSetterNames = {
- "setDeprecatedInt32"};
-
- public void testDeprecatedField() throws Exception {
- Class<?> deprecatedFields = TestDeprecatedFields.class;
- Class<?> deprecatedFieldsBuilder = TestDeprecatedFields.Builder.class;
- for (String name : deprecatedGetterNames) {
- Method method = deprecatedFields.getMethod(name);
- assertTrue("Method " + name + " should be deprecated",
- isDeprecated(method));
- }
- for (String name : deprecatedBuilderGetterNames) {
- Method method = deprecatedFieldsBuilder.getMethod(name);
- assertTrue("Method " + name + " should be deprecated",
- isDeprecated(method));
+public class TextFormatParseLocationTest extends TestCase {
+
+ public void testCreateEmpty() {
+ TextFormatParseLocation location = TextFormatParseLocation.create(-1, -1);
+ assertEquals(TextFormatParseLocation.EMPTY, location);
+ }
+
+ public void testCreate() {
+ TextFormatParseLocation location = TextFormatParseLocation.create(2, 1);
+ assertEquals(2, location.getLine());
+ assertEquals(1, location.getColumn());
+ }
+
+ public void testCreateThrowsIllegalArgumentExceptionForInvalidIndex() {
+ try {
+ TextFormatParseLocation.create(-1, 0);
+ fail("Should throw IllegalArgumentException if line is less than 0");
+ } catch (IllegalArgumentException unused) {
+ // pass
}
- for (String name : deprecatedBuilderSetterNames) {
- Method method = deprecatedFieldsBuilder.getMethod(name, int.class);
- assertTrue("Method " + name + " should be deprecated",
- isDeprecated(method));
+ try {
+ TextFormatParseLocation.create(0, -1);
+ fail("Should throw, column < 0");
+ } catch (IllegalArgumentException unused) {
+ // pass
}
}
-
- private boolean isDeprecated(AnnotatedElement annotated) {
- return annotated.isAnnotationPresent(Deprecated.class);
+
+ public void testHashCode() {
+ TextFormatParseLocation loc0 = TextFormatParseLocation.create(2, 1);
+ TextFormatParseLocation loc1 = TextFormatParseLocation.create(2, 1);
+
+ assertEquals(loc0.hashCode(), loc1.hashCode());
+ assertEquals(
+ TextFormatParseLocation.EMPTY.hashCode(), TextFormatParseLocation.EMPTY.hashCode());
+ }
+
+ public void testEquals() {
+ TextFormatParseLocation loc0 = TextFormatParseLocation.create(2, 1);
+ TextFormatParseLocation loc1 = TextFormatParseLocation.create(1, 2);
+ TextFormatParseLocation loc2 = TextFormatParseLocation.create(2, 2);
+ TextFormatParseLocation loc3 = TextFormatParseLocation.create(2, 1);
+
+ assertEquals(loc0, loc3);
+ assertNotSame(loc0, loc1);
+ assertNotSame(loc0, loc2);
+ assertNotSame(loc1, loc2);
}
}

Powered by Google App Engine
This is Rietveld 408576698