> On Dec 27, 2016, at 5:51 AM, Duncan Jones <dun...@wortharead.com> wrote: > > >> On 27 Dec 2016, at 10:29, Gilles <gil...@harfang.homelinux.org> wrote: >> >> Hi. >> >>> On Tue, 27 Dec 2016 09:54:29 +0000 (UTC), djo...@apache.org wrote: >>> Repository: commons-text >>> Updated Branches: >>> refs/heads/master 1b3e44809 -> 0b1ca53b3 >>> >>> >>> Complete test coverage for RandomStringGenerator >>> >>> Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo >>> Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/0b1ca53b >>> Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/0b1ca53b >>> Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/0b1ca53b >>> >>> Branch: refs/heads/master >>> Commit: 0b1ca53b3e00e74364849a14372e4b3f57c2d3a0 >>> Parents: 1b3e448 >>> Author: duncan <dun...@wortharead.com> >>> Authored: Tue Dec 27 09:54:19 2016 +0000 >>> Committer: duncan <dun...@wortharead.com> >>> Committed: Tue Dec 27 09:54:19 2016 +0000 >>> >>> ---------------------------------------------------------------------- >>> .../org/apache/commons/text/RandomStringGeneratorTest.java | 6 ++++++ >>> 1 file changed, 6 insertions(+) >>> ---------------------------------------------------------------------- >>> >>> >>> http://git-wip-us.apache.org/repos/asf/commons-text/blob/0b1ca53b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java >>> ---------------------------------------------------------------------- >>> diff --git >>> a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java >>> b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java >>> index 2ff7a67..36ce5e0 100644 >>> --- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java >>> +++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java >>> @@ -203,4 +203,10 @@ public class RandomStringGeneratorTest { >>> assertTrue(c == 'b'); >>> } >>> } >>> + >>> + @Test >>> + public void testZeroLength() throws Exception { >>> + RandomStringGenerator generator = new >>> RandomStringGenerator.Builder().build(); >>> + assertEquals("", generator.generate(0)); >>> + } >>> } >> >> A string of length zero hardly qualifies as random. >> Shouldn't "generate(0)" rather raise an exception? >> [I know that "nextInt(1)" is also not random, but what applies to a >> general-purpose low-level utility might not be the best option for >> applications that would use TEXT.] > > I was following the Robustness principle. Asking for a zero-length string is > odd, but as there was a way to interpret that request without throwing an > exception, I did so. >
This makes sense to me. It feels like every random string generator, regardless of the underlying distribution, on the request for the string of length 0 should return a string from the Kleene closure over the null set. -Rob > Duncan > >> >> Regards, >> Gilles >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> For additional commands, e-mail: dev-h...@commons.apache.org >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org