testVersionVersionCompareViaRegistry(version1, version2, result);
}
protected void testVersionVersionCompareViaRegistry(Object version1, Object version2, int result)
{
VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
if (result < 0)
{
assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0);
assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0);
}
else if (result > 0)
{
assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0);
assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0);
}
else
{
assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0);
assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0);
}
if (result == 0)
{
assertTrue("Expected " + version1 + ".equals(" + version2 + ") to be true", registry.same(version1, version2));
assertTrue("Expected " + version2 + ".equals(" + version1 + ") to be true", registry.same(version2, version1));
}
else
{
assertFalse("Expected " + version1 + ".equals(" + version2 + ") to be false", registry.same(version1, version2));
assertFalse("Expected " + version2 + ".equals(" + version1 + ") to be false", registry.same(version2, version1));
}
}