Github user jaredjstewart commented on a diff in the pull request: https://github.com/apache/geode/pull/724#discussion_r134075476 --- Diff: geode-core/src/test/java/org/apache/geode/internal/process/lang/AvailablePidTest.java --- @@ -100,7 +105,53 @@ public void findAvailablePidsShouldReturnNoDuplicatedPids() throws Exception { assertThatNoPidIsDuplicated(availablePid.findAvailablePids(8)); } - private void assertThatNoPidIsDuplicated(int[] pids) { + @Test(timeout = DEFAULT_TIMEOUT_MILLIS) + public void findAvailablePidShouldReturnGreaterThanOrEqualToLowerBound() throws Exception { + availablePid = new AvailablePid(new AvailablePid.Bounds(1, 3)); + + int pid = availablePid.findAvailablePid(); + + assertThat(pid).isGreaterThanOrEqualTo(1); + } + + @Test(timeout = DEFAULT_TIMEOUT_MILLIS) + public void findAvailablePidShouldReturnLessThanOrEqualToUpperBound() throws Exception { + availablePid = new AvailablePid(new AvailablePid.Bounds(1, 3)); + + int pid = availablePid.findAvailablePid(); + + assertThat(pid).isLessThanOrEqualTo(3); + } + + @Test + public void randomLowerBoundIsInclusive() throws Exception { + availablePid = new AvailablePid(new AvailablePid.Bounds(1, 3)); + + await().atMost(10, SECONDS).until(() -> assertThat(availablePid.random()).isEqualTo(1)); + } + + @Test + public void randomUpperBoundIsInclusive() throws Exception { + availablePid = new AvailablePid(new AvailablePid.Bounds(1, 3)); + + await().atMost(10, SECONDS).until(() -> assertThat(availablePid.random()).isEqualTo(3)); --- End diff -- This is a clever way to test that lower and upper bounds are potential output values!
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---