-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformat AutoValue source code using google-java-format. A few of the…
… changes are arguably for the worse, but it's worth having a consistent format. RELNOTES=Reformatted AutoValue source code using google-java-format. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198512874
- Loading branch information
1 parent
0ffe45c
commit 41d78d2
Showing
72 changed files
with
4,611 additions
and
3,937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,7 @@ | |
import com.google.auto.value.AutoValue; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author [email protected] (Éamonn McManus) | ||
*/ | ||
/** @author [email protected] (Éamonn McManus) */ | ||
public class PackagelessNestedValueType { | ||
@AutoValue | ||
public abstract static class Nested { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,7 @@ | |
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author [email protected] (Éamonn McManus) | ||
*/ | ||
/** @author [email protected] (Éamonn McManus) */ | ||
public class NestedValueType { | ||
@AutoValue | ||
public abstract static class Nested { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,7 @@ | |
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
/** | ||
* @author [email protected] (Éamonn McManus) | ||
*/ | ||
/** @author [email protected] (Éamonn McManus) */ | ||
@RunWith(JUnit4.class) | ||
public class PackagelessValueTypeTest { | ||
@Test | ||
|
@@ -38,8 +36,8 @@ public void testPackagelessValueType() { | |
assertSame(happy, simple.string()); | ||
assertEquals(testInt, simple.integer()); | ||
assertSame(testMap, simple.map()); | ||
assertEquals("PackagelessValueType{string=happy, integer=23, map={happy=23}}", | ||
simple.toString()); | ||
assertEquals( | ||
"PackagelessValueType{string=happy, integer=23, map={happy=23}}", simple.toString()); | ||
int expectedHashCode = 1; | ||
expectedHashCode = (expectedHashCode * 1000003) ^ happy.hashCode(); | ||
expectedHashCode = (expectedHashCode * 1000003) ^ ((Object) testInt).hashCode(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,47 +27,67 @@ | |
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
/** | ||
* @author [email protected] (Éamonn McManus) | ||
*/ | ||
/** @author [email protected] (Éamonn McManus) */ | ||
@RunWith(JUnit4.class) | ||
public class AutoAnnotationDefaultsTest { | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@interface EverythingWithDefaults { | ||
byte aByte() default 1; | ||
|
||
short aShort() default 2; | ||
|
||
int anInt() default 3; | ||
|
||
long aLong() default Long.MAX_VALUE; | ||
|
||
float aFloat() default Float.MAX_VALUE; | ||
|
||
double aDouble() default -Double.MAX_VALUE; | ||
|
||
char aChar() default '#'; | ||
|
||
boolean aBoolean() default true; | ||
|
||
String aString() default "maybe\nmaybe not\n"; | ||
|
||
String spaces() default " ( x ) , ( y )"; // ensure the formatter doesn't eat spaces | ||
|
||
MyEnum anEnum() default MyEnum.TWO; | ||
|
||
byte[] bytes() default {-1, 0, 1}; | ||
|
||
short[] shorts() default {-2, 0, 2}; | ||
|
||
int[] ints() default {}; | ||
|
||
long[] longs() default {-Long.MAX_VALUE}; | ||
|
||
float[] floats() default { | ||
-Float.MIN_VALUE, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NaN, | ||
}; | ||
|
||
double[] doubles() default { | ||
-Double.MIN_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN, | ||
}; | ||
|
||
char[] chars() default {'f', '\n', '\uffef'}; | ||
|
||
boolean[] booleans() default {false, true}; | ||
|
||
String[] strings() default {"", "\uffef\n"}; | ||
|
||
MyEnum[] enums() default {MyEnum.ONE, MyEnum.TWO}; | ||
} | ||
|
||
@AutoAnnotation static EverythingWithDefaults newEverythingWithDefaults() { | ||
@AutoAnnotation | ||
static EverythingWithDefaults newEverythingWithDefaults() { | ||
return new AutoAnnotation_AutoAnnotationDefaultsTest_newEverythingWithDefaults(); | ||
} | ||
|
||
@Test | ||
public void testDefaults() throws Exception { | ||
@EverythingWithDefaults class Annotated {} | ||
@EverythingWithDefaults | ||
class Annotated {} | ||
EverythingWithDefaults expected = Annotated.class.getAnnotation(EverythingWithDefaults.class); | ||
EverythingWithDefaults actual = newEverythingWithDefaults(); | ||
|
||
|
@@ -79,18 +99,21 @@ public void testDefaults() throws Exception { | |
Object expectedValue = member.invoke(expected); | ||
Object actualValue = member.invoke(actual); | ||
if (!equal(expectedValue, actualValue)) { | ||
differencesBuilder.append("For ").append(name) | ||
.append(" expected <").append(string(expectedValue)) | ||
.append("> but was <").append(string(actualValue)).append(">\n"); | ||
differencesBuilder | ||
.append("For ") | ||
.append(name) | ||
.append(" expected <") | ||
.append(string(expectedValue)) | ||
.append("> but was <") | ||
.append(string(actualValue)) | ||
.append(">\n"); | ||
} | ||
} | ||
String differences = differencesBuilder.toString(); | ||
assertTrue(differences, differences.isEmpty()); | ||
|
||
// All the members were the same. Check that the equals and hashCode results say so too. | ||
new EqualsTester() | ||
.addEqualityGroup(expected, actual) | ||
.testEquals(); | ||
new EqualsTester().addEqualityGroup(expected, actual).testEquals(); | ||
} | ||
|
||
private static boolean equal(Object x, Object y) { | ||
|
Oops, something went wrong.