String goodObjects[] = {
"12345",
"ABCDF"
};
ByteString goodByteStrings[] = {
ByteString.copyAvroString("qwert", false)
};
Object badObjects[] = {
"", "1", "12", "123", "1234", "1234\u0100", "123456",
1, 2.0f, 3.0, 4L, new DataMap(), new DataList()
};
ByteString badByteStrings[] = {
ByteString.copyAvroString("", false),
ByteString.copyAvroString("a", false),
ByteString.copyAvroString("ab", false),
ByteString.copyAvroString("abc", false),
ByteString.copyAvroString("abcd", false),
ByteString.copyAvroString("abcdef", false)
};
Integer lastHashCode = null;
ByteString lastByteString = null;
for (String o : goodObjects)
{
Exception exc = null;
Fixed5 fixed = null;
try
{
fixed = new Fixed5(o);
}
catch (Exception e)
{
exc = e;
}
assertNull(exc);
// equals
ByteString expectedByteString = ByteString.copyAvroString(o, false);
assertEquals(fixed.data(), expectedByteString);
assertTrue(fixed.equals(new Fixed5(expectedByteString)));
if (lastByteString != null)
{
assertFalse(fixed.equals(lastByteString));
}
assertFalse(fixed.equals(null));
assertFalse(fixed.equals(new Object()));
// hashCode
int newHashCode = fixed.hashCode();
if (lastHashCode != null)
{
assertTrue(newHashCode != lastHashCode);
}
// toString
assertEquals(expectedByteString.toString(), fixed.toString());
lastHashCode = newHashCode;
lastByteString = expectedByteString;
// clone and copy