Move stray tests to a test sub package. Reduce tests in TestCoordMap.

TestCoordMap: Use less samples with extra testing not being set.
This commit is contained in:
asofold 2017-04-24 17:27:06 +02:00
parent 2ff5415601
commit f02a11e404
7 changed files with 78 additions and 46 deletions

View File

@ -66,6 +66,9 @@ public class TestCoordMap {
}
}
private final boolean extraTesting = BuildParameters.testLevel > 0;
private final int suggestedSamples = extraTesting ? 40000 : 1250;
public int[][] getRandomCoords(int n, int max, Random random) {
final int [][] coords = new int[n][3];
for (int i = 0; i < n; i++){
@ -304,9 +307,7 @@ public class TestCoordMap {
final Random random = new Random(System.nanoTime() - (System.currentTimeMillis() % 2 == 1 ? 37 : 137));
final boolean e = BuildParameters.testLevel > 0;
final int n = e ? 40000 : 6000; // Number of coordinates.
final int n = suggestedSamples; // Number of coordinates.
final int max = 800; // Coordinate maximum.
int [][] coords = getUniqueRandomCoords(n, max, random);
@ -328,9 +329,7 @@ public class TestCoordMap {
final Random random = new Random(System.nanoTime() - (System.currentTimeMillis() % 2 == 1 ? 37 : 137));
final boolean e = BuildParameters.testLevel > 0;
final int n = e ? 40000 : 6000; // Number of coordinates.
final int n = suggestedSamples; // Number of coordinates.
final int max = 800; // Coordinate maximum.
// Preparecoordinates.

View File

@ -1,36 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus;
import static org.junit.Assert.fail;
import org.junit.Test;
public class NoobsTest {
@Test
public void testSmallDoubles() {
double x;
x = Double.MIN_VALUE;
if (x <= 0.0 || !(x > 0.0)) {
fail("noob");
}
x = -Double.MIN_VALUE;
if (x >= 0.0 || !(x < 0.0)) {
fail("noob");
}
}
}

View File

@ -0,0 +1,69 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.test;
import static org.junit.Assert.fail;
import org.junit.Test;
public class NoobsTest {
@Test
public void testSmallDoubles() {
double x;
x = Double.MIN_VALUE;
if (x <= 0.0 || !(x > 0.0)) {
fail("noob");
}
x = -Double.MIN_VALUE;
if (x >= 0.0 || !(x < 0.0)) {
fail("noob");
}
}
@Test
public void testSimpleRegex() {
String ncpMovingAndFurther = "(^|.*,)(ncp\\.moving($|,.*|\\..*))";
String[][] samplesMatch = new String[][] {
{"x|y", "^x\\|y$"},
{"dummy", "dummy"},
{"lark", "(park|lark|bark)"},
{"lark", "(park|(lark$)|bark)"},
{"ncp.moving.survivalfly.hover", "(^|.*,)(ncp\\.moving\\.).*"}, // Simplified
{"ncp.moving.survivalfly.hover", ncpMovingAndFurther},
{"ncp.moving", ncpMovingAndFurther},
{"ncp.moving,random", ncpMovingAndFurther},
{"random,ncp.moving", ncpMovingAndFurther},
{"random,ncp.moving,fandom", ncpMovingAndFurther},
};
String[][] samplesNotMatch = new String[][] {
{"dummy", "yummd"},
{"larkX", "(park|(lark$)|bark)"},
{"ncp.movingApes", ncpMovingAndFurther},
{"ncp.moving.survivalfly.hover", "ncp\\.moving($|,.*)"},
};
for (final String[] pair : samplesMatch) {
if (!pair[0].matches(pair[1])) {
fail("Expect match: " + pair[0] + " <- " + pair[1]);
}
}
for (final String[] pair : samplesNotMatch) {
if (pair[0].matches(pair[1])) {
fail("Expect not match: " + pair[0] + " <- " + pair[1]);
}
}
}
}

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus;
package fr.neatmonster.nocheatplus.test;
import static org.junit.Assert.fail;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus;
package fr.neatmonster.nocheatplus.test;
import static org.junit.Assert.fail;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus;
package fr.neatmonster.nocheatplus.test;
import static org.junit.Assert.fail;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus;
package fr.neatmonster.nocheatplus.test;
import static org.junit.Assert.fail;