mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-30 03:16:12 +00:00
Trimming profile names to fit byte budget and remove leading/trailing spaces.
This commit is contained in:
committed by
Greyson Parrelli
parent
7d15c602a6
commit
e7f568e162
@@ -10,7 +10,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class ProfileNameTest {
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void givenEmpty_thenIExpectSaneDefaults() {
|
||||
// GIVEN
|
||||
ProfileName profileName = ProfileName.EMPTY;
|
||||
@@ -23,7 +23,7 @@ public final class ProfileNameTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNullProfileName_whenIFromDataString_thenIExpectSaneDefaults() {
|
||||
public void givenNullProfileName_whenIFromSerialized_thenIExpectExactlyEmpty() {
|
||||
// GIVEN
|
||||
ProfileName profileName = ProfileName.fromSerialized(null);
|
||||
|
||||
@@ -128,6 +128,7 @@ public final class ProfileNameTest {
|
||||
|
||||
// THEN
|
||||
assertEquals("Blank String should be returned (For back compat)", "", data);
|
||||
assertEquals("Family", name.getFamilyName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,4 +162,18 @@ public final class ProfileNameTest {
|
||||
assertEquals("GivenSomeVeryLongNameSomeV", name.getGivenName());
|
||||
assertEquals("FamilySomeVeryLongNameSome", name.getFamilyName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenProfileNameWithGivenNameAndFamilyNameWithSpaces_whenIToDataString_thenIExpectTrimmedProfileName() {
|
||||
// GIVEN
|
||||
ProfileName name = ProfileName.fromParts(" Given ", " Family");
|
||||
|
||||
// WHEN
|
||||
String data = name.serialize();
|
||||
|
||||
// THEN
|
||||
assertEquals(data, "Given\0Family");
|
||||
assertEquals(name.getGivenName(), "Given");
|
||||
assertEquals(name.getFamilyName(), "Family");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user