Reduce runtime of CidrsTests#testValidCombinations

This commit reduces the running time of CidrsTests#testValidCombinations
by hoisting some costly repeated operations outside of the inner test
loop.
This commit is contained in:
Jason Tedor 2015-12-23 16:07:13 -05:00
parent 76fa9023b6
commit 6ab922c5a0
1 changed files with 2 additions and 1 deletions

View File

@ -133,8 +133,9 @@ public class CidrsTests extends ESTestCase {
public void testValidCombinations() {
for (long i = 0; i < (1 << 16); i++) {
String octetsString = Cidrs.octetsToString(Cidrs.longToOctets(i << 16));
for (int mask = 16; mask <= 32; mask++) {
String test = Cidrs.octetsToCIDR(Cidrs.longToOctets(i << 16), mask);
String test = octetsString + "/" + mask;
long[] actual = Cidrs.cidrMaskToMinMax(test);
assertNotNull(test, actual);
assertEquals(test, 2, actual.length);