-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tries to parse given version in `ComparableVersion` disregarding non-numeric characters. This allows parsing Docker CLI versions like `18.06.0-dev`.
- Loading branch information
Showing
2 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
core/src/test/java/org/testcontainers/utility/ComparableVersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.testcontainers.utility; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
|
||
@RunWith(Parameterized.class) | ||
public class ComparableVersionTest { | ||
|
||
private final int[] expected; | ||
private final String given; | ||
|
||
public ComparableVersionTest(final String given, final int[] expected) { | ||
this.given = given; | ||
this.expected = expected; | ||
} | ||
|
||
@Test | ||
public void shouldParseVersions() { | ||
assertArrayEquals(expected, ComparableVersion.parseVersion(given)); | ||
} | ||
|
||
@Parameters(name = "Parsed version: {0}={1}") | ||
public static Iterable<Object[]> data() { | ||
return Arrays.asList(new Object[][] { | ||
{"1.2.3", new int[] {1, 2, 3}}, | ||
{"", new int[0]}, | ||
{"1", new int[] {1}}, | ||
{"1.2.3.4.5.6.7", new int[] {1, 2, 3, 4, 5, 6, 7}}, | ||
{"1.2-dev", new int[] {1, 2}}, | ||
{"18.06.0-dev", new int[] {18, 6}}, | ||
}); | ||
} | ||
|
||
} |