From f88cac039eaa834859b2b2e748c0d8bb0ad82e67 Mon Sep 17 00:00:00 2001 From: Shawn O. Pearce Date: Tue, 5 Jan 2010 19:14:48 -0800 Subject: Move TestRng to our JUnit helper package Other test suites may find this useful, especially when trying to defeat the pack file compression with random data files. Change-Id: Ic00a4ac626af7a1c94d18ee99305e295b267b1a3 Signed-off-by: Shawn O. Pearce --- .../org/eclipse/jgit/util/TemporaryBufferTest.java | 2 + .../tst/org/eclipse/jgit/util/TestRng.java | 67 ---------------------- 2 files changed, 2 insertions(+), 67 deletions(-) delete mode 100644 org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TestRng.java (limited to 'org.eclipse.jgit.test') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java index eb24172249..e1f802b3d1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java @@ -48,6 +48,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; +import org.eclipse.jgit.junit.TestRng; + import junit.framework.TestCase; public class TemporaryBufferTest extends TestCase { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TestRng.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TestRng.java deleted file mode 100644 index 4110b55baa..0000000000 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TestRng.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2008, Google Inc. - * and other copyright owners as documented in the project's IP log. - * - * This program and the accompanying materials are made available - * under the terms of the Eclipse Distribution License v1.0 which - * accompanies this distribution, is reproduced below, and is - * available at http://www.eclipse.org/org/documents/edl-v10.php - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * - Neither the name of the Eclipse Foundation, Inc. nor the - * names of its contributors may be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.eclipse.jgit.util; - -/** Toy RNG to ensure we get predictable numbers during unit tests. */ -public class TestRng { - private int next; - - public TestRng(final String seed) { - next = 0; - for (int i = 0; i < seed.length(); i++) - next = next * 11 + seed.charAt(i); - } - - public byte[] nextBytes(final int cnt) { - final byte[] r = new byte[cnt]; - for (int i = 0; i < cnt; i++) - r[i] = (byte) nextInt(); - return r; - } - - public int nextInt() { - next = next * 1103515245 + 12345; - return next; - } -} -- cgit v1.2.3