### Question:
VersionUtil { public static int fromVersionString(String verStr) { if (verStr == null || verStr.length() < 1) { return 0; } int[] versions = new int[] {0, 0, 0, 0}; int index = 0; String segment; int cur = 0; int pos; do { if (index >= versions.length) { return 0; } pos = verStr.indexOf('.', cur); if (pos == -1) { segment = verStr.substring(cur); } else if (cur < pos) { segment = verStr.substring(cur, pos); } else { return 0; } versions[index] = parseInt(segment); if (versions[index] < 0 || versions[index] > 255) { return 0; } cur = pos + 1; index ++; } while (pos > 0); return ((versions[0] & 0xff) << 24) | ((versions[1] & 0xff) << 16) | ((versions[2] & 0xff) << 8) | (versions[3] & 0xff); } private  VersionUtil(); static String getVersion(String defaultVersion); static int fromVersionString(String verStr);  }### Answer:
@Test public void testFromVersionString() { assertEquals(0x01020300, VersionUtil.fromVersionString("1.2.3")); assertEquals(0x01020304, VersionUtil.fromVersionString("1.2.3.4")); assertEquals(0x0102ff04, VersionUtil.fromVersionString("1.2.255.4")); assertEquals(0xffffffff, VersionUtil.fromVersionString("255.255.255.255")); assertEquals(0, VersionUtil.fromVersionString("1.255.256.0")); assertEquals(0x01020000, VersionUtil.fromVersionString("1.2.")); assertEquals(0x01000000, VersionUtil.fromVersionString("1")); assertEquals(0x01020000, VersionUtil.fromVersionString("1.2")); assertEquals(0, VersionUtil.fromVersionString("test")); assertEquals(0x01020300, VersionUtil.fromVersionString("1.2.3-")); assertEquals(0x01020300, VersionUtil.fromVersionString("1.2.3b")); assertEquals(0x01023c00, VersionUtil.fromVersionString("1.2.60.sec9")); assertEquals(0x01023c00, VersionUtil.fromVersionString("1.2.60-internal")); }