-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extend AString from Parcelable
- Loading branch information
Showing
23 changed files
with
261 additions
and
40 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
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
android { | ||
compileSdkVersion 30 | ||
compileSdkVersion 31 | ||
|
||
defaultConfig { | ||
minSdkVersion 19 | ||
targetSdkVersion 30 | ||
targetSdkVersion 31 | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
astring/src/androidTest/java/xyz/tynn/astring/AssertParcelable.java
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2021 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring; | ||
|
||
import static android.os.Parcel.obtain; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
|
||
class AssertParcelable { | ||
|
||
private static ClassLoader getClassloader() { | ||
return AssertParcelable.class.getClassLoader(); | ||
} | ||
|
||
static <T extends Parcelable> void assertParcelable(T expected) { | ||
Parcel parcel = obtain(); | ||
parcel.writeValue(expected); | ||
parcel.setDataPosition(0); | ||
assertEquals(expected, parcel.readValue(getClassloader())); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
astring/src/androidTest/java/xyz/tynn/astring/ParcelableAStringTest.java
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2021 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring; | ||
|
||
import static xyz.tynn.astring.AssertParcelable.assertParcelable; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.Date; | ||
|
||
public class ParcelableAStringTest { | ||
|
||
public static final int RES_ID = 123; | ||
public static final int QUANTITY = 456; | ||
public static final Object[] FORMAT_ARGS = {"arg1", 2, 3L, 4.5, 6F, new Date()}; | ||
|
||
@Test | ||
public void CharSequence_should_implement_parcelable() { | ||
assertParcelable(new CharSequenceWrapper("test-string")); | ||
} | ||
|
||
@Test | ||
public void NullValueWrapper_should_implement_parcelable() { | ||
assertParcelable(NullValueWrapper.I); | ||
} | ||
|
||
@Test | ||
public void QuantityStringResourceDelegate_should_implement_parcelable() { | ||
assertParcelable(new QuantityStringResourceDelegate(RES_ID, QUANTITY, FORMAT_ARGS)); | ||
} | ||
|
||
@Test | ||
public void QuantityTextResourceDelegate_should_implement_parcelable() { | ||
assertParcelable(new QuantityTextResourceDelegate(RES_ID, QUANTITY)); | ||
} | ||
|
||
@Test | ||
public void StringResourceDelegate_should_implement_parcelable() { | ||
assertParcelable(new StringResourceDelegate(RES_ID, FORMAT_ARGS)); | ||
} | ||
|
||
@Test | ||
public void TextResourceDelegate_should_implement_parcelable() { | ||
assertParcelable(new TextResourceDelegate(RES_ID)); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.