assert -> assertTrue to avoid collision with new Java assert keyword.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@700 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-04-11 04:07:42 +00:00
parent 432fd659bf
commit 8daf88066b
8 changed files with 52 additions and 46 deletions
@@ -1,5 +1,5 @@
// //
// $Id: ProximityTrackerTest.java,v 1.1 2001/12/15 03:19:03 mdb Exp $ // $Id: ProximityTrackerTest.java,v 1.2 2002/04/11 04:07:42 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -83,8 +83,9 @@ public class ProximityTrackerTest extends TestCase
String tps = tp.x + "," + tp.y; String tps = tp.x + "," + tp.y;
String cps = cp.x + "," + cp.y; String cps = cp.x + "," + cp.y;
String ps = x + "," + y; String ps = x + "," + y;
assert(ps + " => " + cps + " (" + cdist + ") ! " + assertTrue(ps + " => " + cps + " (" + cdist + ") ! " +
tps + " (" + tdist + ")", tp.equals(cp) || (tdist == cdist)); tps + " (" + tdist + ")",
tp.equals(cp) || (tdist == cdist));
} }
} }
@@ -1,5 +1,5 @@
// //
// $Id: ArrayIntSetTest.java,v 1.1 2002/02/03 07:10:16 mdb Exp $ // $Id: ArrayIntSetTest.java,v 1.2 2002/04/11 04:07:42 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -48,7 +48,7 @@ public class ArrayIntSetTest extends TestCase
int[] values = { 1, 3, 5, 7, 9 }; int[] values = { 1, 3, 5, 7, 9 };
int[] setvals = set.toIntArray(); int[] setvals = set.toIntArray();
assert("values equal", Arrays.equals(values, setvals)); assertTrue("values equal", Arrays.equals(values, setvals));
} }
public static Test suite () public static Test suite ()
@@ -1,5 +1,5 @@
// //
// $Id: ConfigUtilTest.java,v 1.2 2002/04/01 01:56:21 mdb Exp $ // $Id: ConfigUtilTest.java,v 1.3 2002/04/11 04:07:42 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -39,7 +39,7 @@ public class ConfigUtilTest extends TestCase
try { try {
String path = "/rsrc/util/test.properties"; String path = "/rsrc/util/test.properties";
Properties props = ConfigUtil.loadInheritedProperties(path); Properties props = ConfigUtil.loadInheritedProperties(path);
assert("props valid", props.toString().equals(DUMP)); assertTrue("props valid", props.toString().equals(DUMP));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(System.err); e.printStackTrace(System.err);
@@ -1,5 +1,5 @@
// //
// $Id: HashIntMapTest.java,v 1.2 2001/12/13 01:31:23 mdb Exp $ // $Id: HashIntMapTest.java,v 1.3 2002/04/11 04:07:42 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -42,14 +42,14 @@ public class HashIntMapTest extends TestCase
// check the table contents // check the table contents
for (int i = 10; i < 20; i++) { for (int i = 10; i < 20; i++) {
Integer val = (Integer)table.get(i); Integer val = (Integer)table.get(i);
assert("get(" + i + ") == " + i, val.intValue() == i); assertTrue("get(" + i + ") == " + i, val.intValue() == i);
} }
String keys = StringUtil.toString(table.keys()); String keys = StringUtil.toString(table.keys());
assert("keys valid", keys.equals(TEST1)); assertTrue("keys valid", keys.equals(TEST1));
String elems = StringUtil.toString(table.elements()); String elems = StringUtil.toString(table.elements());
assert("elems valid", elems.equals(TEST1)); assertTrue("elems valid", elems.equals(TEST1));
// remove some entries and attempt to remove some non-entries // remove some entries and attempt to remove some non-entries
for (int i = 12; i < 22; i++) { for (int i = 12; i < 22; i++) {
@@ -57,10 +57,10 @@ public class HashIntMapTest extends TestCase
} }
keys = StringUtil.toString(table.keys()); keys = StringUtil.toString(table.keys());
assert("keys valid", keys.equals(TEST2)); assertTrue("keys valid", keys.equals(TEST2));
elems = StringUtil.toString(table.elements()); elems = StringUtil.toString(table.elements());
assert("elems valid", elems.equals(TEST2)); assertTrue("elems valid", elems.equals(TEST2));
// now try some serialization // now try some serialization
populateTable(table); populateTable(table);
@@ -80,7 +80,7 @@ public class HashIntMapTest extends TestCase
// check the table contents // check the table contents
for (int i = 10; i < 20; i++) { for (int i = 10; i < 20; i++) {
Integer val = (Integer)table.get(i); Integer val = (Integer)table.get(i);
assert("get(" + i + ") == " + i, val.intValue() == i); assertTrue("get(" + i + ") == " + i, val.intValue() == i);
} }
tmpfile.delete(); tmpfile.delete();
@@ -1,5 +1,5 @@
// //
// $Id: IntListUtilTest.java,v 1.3 2002/02/03 07:09:50 mdb Exp $ // $Id: IntListUtilTest.java,v 1.4 2002/04/11 04:07:42 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -40,46 +40,49 @@ public class IntListUtilTest extends TestCase
list = IntListUtil.add(list, 2); list = IntListUtil.add(list, 2);
// System.out.println("add(2): " + StringUtil.toString(list)); // System.out.println("add(2): " + StringUtil.toString(list));
assert("add(2)", Arrays.equals(list, new int[] { 2, 0, 0, 0 })); assertTrue("add(2)", Arrays.equals(list, new int[] { 2, 0, 0, 0 }));
list = IntListUtil.add(list, 5); list = IntListUtil.add(list, 5);
// System.out.println("add(5): " + StringUtil.toString(list)); // System.out.println("add(5): " + StringUtil.toString(list));
assert("add(5)", Arrays.equals(list, new int[] { 2, 5, 0, 0 })); assertTrue("add(5)", Arrays.equals(list, new int[] { 2, 5, 0, 0 }));
IntListUtil.clear(list, 2); IntListUtil.clear(list, 2);
// System.out.println("clear(2): " + StringUtil.toString(list)); // System.out.println("clear(2): " + StringUtil.toString(list));
assert("clear(2)", Arrays.equals(list, new int[] { 0, 5, 0, 0 })); assertTrue("clear(2)", Arrays.equals(list, new int[] { 0, 5, 0, 0 }));
boolean contains5 = IntListUtil.contains(list, 5); boolean contains5 = IntListUtil.contains(list, 5);
// System.out.println("contains(newBar): " + contains5); // System.out.println("contains(newBar): " + contains5);
assert("contains(5)", contains5); assertTrue("contains(5)", contains5);
IntListUtil.removeAt(list, 1); IntListUtil.removeAt(list, 1);
// System.out.println("removeAt(1): " + StringUtil.toString(list)); // System.out.println("removeAt(1): " + StringUtil.toString(list));
assert("removeAt(1)", Arrays.equals(list, new int[] { 0, 0, 0, 0 })); assertTrue("removeAt(1)",
Arrays.equals(list, new int[] { 0, 0, 0, 0 }));
list = IntListUtil.add(list, 0, 2); list = IntListUtil.add(list, 0, 2);
list = IntListUtil.add(list, 1, 5); list = IntListUtil.add(list, 1, 5);
// System.out.println("add(0, 2) + add(1, 5): " + // System.out.println("add(0, 2) + add(1, 5): " +
// StringUtil.toString(list)); // StringUtil.toString(list));
assert("add(0, 2) + add(1, 5))", assertTrue("add(0, 2) + add(1, 5))",
Arrays.equals(list, new int[] { 2, 5, 0, 0 })); Arrays.equals(list, new int[] { 2, 5, 0, 0 }));
IntListUtil.remove(list, 2); IntListUtil.remove(list, 2);
// System.out.println("remove(2): " + StringUtil.toString(list)); // System.out.println("remove(2): " + StringUtil.toString(list));
assert("removeAt(2)", Arrays.equals(list, new int[] { 5, 0, 0, 0 })); assertTrue("removeAt(2)",
Arrays.equals(list, new int[] { 5, 0, 0, 0 }));
list = IntListUtil.add(list, 0, 2); list = IntListUtil.add(list, 0, 2);
list = IntListUtil.add(list, 1, 5); list = IntListUtil.add(list, 1, 5);
list = IntListUtil.add(list, 2, 6); list = IntListUtil.add(list, 2, 6);
// System.out.println("add(0, 2) + add(1, 5) + add(2, 6): " + // System.out.println("add(0, 2) + add(1, 5) + add(2, 6): " +
// StringUtil.toString(list)); // StringUtil.toString(list));
assert("add(0, 2) + add(1, 5) + add(2, 6)", assertTrue("add(0, 2) + add(1, 5) + add(2, 6)",
Arrays.equals(list, new int[] { 5, 2, 5, 6 })); Arrays.equals(list, new int[] { 5, 2, 5, 6 }));
IntListUtil.removeAt(list, 0); IntListUtil.removeAt(list, 0);
// System.out.println("removeAt(0): " + StringUtil.toString(list)); // System.out.println("removeAt(0): " + StringUtil.toString(list));
assert("removeAt(0)", Arrays.equals(list, new int[] { 2, 5, 6, 0 })); assertTrue("removeAt(0)",
Arrays.equals(list, new int[] { 2, 5, 6, 0 }));
int[] tl = IntListUtil.testAndAdd(list, 5); int[] tl = IntListUtil.testAndAdd(list, 5);
// if (tl == null) { // if (tl == null) {
@@ -90,7 +93,7 @@ public class IntListUtilTest extends TestCase
// System.out.println("testAndAdd(5): added: " + // System.out.println("testAndAdd(5): added: " +
// StringUtil.toString(list)); // StringUtil.toString(list));
// } // }
assert("testAndAdd(5)", tl == null); assertTrue("testAndAdd(5)", tl == null);
tl = IntListUtil.testAndAdd(list, 7); tl = IntListUtil.testAndAdd(list, 7);
// if (tl == null) { // if (tl == null) {
@@ -101,11 +104,12 @@ public class IntListUtilTest extends TestCase
// System.out.println("testAndAdd(7): added: " + // System.out.println("testAndAdd(7): added: " +
// StringUtil.toString(list)); // StringUtil.toString(list));
// } // }
assert("testAndAdd(7)", tl != null); assertTrue("testAndAdd(7)", tl != null);
IntListUtil.removeAt(list, 0); IntListUtil.removeAt(list, 0);
// System.out.println("removeAt(0): " + StringUtil.toString(list)); // System.out.println("removeAt(0): " + StringUtil.toString(list));
assert("removeAt(0)", Arrays.equals(list, new int[] { 5, 6, 7, 0 })); assertTrue("removeAt(0)",
Arrays.equals(list, new int[] { 5, 6, 7, 0 }));
} }
public static Test suite () public static Test suite ()
@@ -1,5 +1,5 @@
// //
// $Id: QuickSortTest.java,v 1.1 2002/02/19 03:37:32 mdb Exp $ // $Id: QuickSortTest.java,v 1.2 2002/04/11 04:07:42 mdb Exp $
package com.samskivert.util; package com.samskivert.util;
@@ -33,8 +33,8 @@ public class QuickSortTest extends TestCase
a[n] = new Integer(n / d); a[n] = new Integer(n / d);
QuickSort.csort (a, 0, n, comp); QuickSort.csort (a, 0, n, comp);
for (int i = 0; i <= n; i++) { for (int i = 0; i <= n; i++) {
assert("Failure for up " + n + "/" + d, assertTrue("Failure for up " + n + "/" + d,
a[i].intValue() == i / d); a[i].intValue() == i / d);
} }
} }
} }
@@ -47,8 +47,8 @@ public class QuickSortTest extends TestCase
} }
QuickSort.csort (a, 0, n, comp); QuickSort.csort (a, 0, n, comp);
for (int i = 0; i <= n; i++) { for (int i = 0; i <= n; i++) {
assert("Failure for down " + n + "/" + d, assertTrue("Failure for down " + n + "/" + d,
a[i].intValue() == i / d); a[i].intValue() == i / d);
} }
} }
} }
@@ -63,21 +63,21 @@ public class QuickSortTest extends TestCase
QuickSort.csort (a, 0, n, comp); QuickSort.csort (a, 0, n, comp);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assert("Failure for random " + n, assertTrue("Failure for random " + n,
a[i].intValue() <= a[i+1].intValue()); a[i].intValue() <= a[i+1].intValue());
} }
QuickSort.csort (a, 0, n, comp); QuickSort.csort (a, 0, n, comp);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assert("Failure for random " + n + " (resort)", assertTrue("Failure for random " + n + " (resort)",
a[i].intValue() <= a[i+1].intValue()); a[i].intValue() <= a[i+1].intValue());
} }
a[rand(n+1)] = new Integer(rand(30000)); a[rand(n+1)] = new Integer(rand(30000));
QuickSort.csort (a, 0, n, comp); QuickSort.csort (a, 0, n, comp);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
assert("Failure for random " + n + " (resort 2)", assertTrue("Failure for random " + n + " (resort 2)",
a[i].intValue() <= a[i+1].intValue()); a[i].intValue() <= a[i+1].intValue());
} }
} }
// System.out.println("successfully sorted " + tests + // System.out.println("successfully sorted " + tests +
@@ -1,5 +1,5 @@
// //
// $Id: StringUtilTest.java,v 1.2 2002/01/30 18:21:15 mdb Exp $ // $Id: StringUtilTest.java,v 1.3 2002/04/11 04:07:42 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -38,16 +38,17 @@ public class StringUtilTest extends TestCase
// split the source string into tokens // split the source string into tokens
String[] tokens = StringUtil.parseStringArray(source); String[] tokens = StringUtil.parseStringArray(source);
assert("tokens.length == 7", tokens.length == 7); assertTrue("tokens.length == 7", tokens.length == 7);
// now join them back together // now join them back together
String joined = StringUtil.joinEscaped(tokens); String joined = StringUtil.joinEscaped(tokens);
assert("joined.equals(source)", joined.equals(source)); assertTrue("joined.equals(source)", joined.equals(source));
// make sure null to empty string works // make sure null to empty string works
tokens = new String[] { "this", null, "is", null, "a", null, "test" }; tokens = new String[] { "this", null, "is", null, "a", null, "test" };
joined = StringUtil.joinEscaped(tokens); joined = StringUtil.joinEscaped(tokens);
assert("null elements work", joined.equals("this, , is, , a, , test")); assertTrue("null elements work",
joined.equals("this, , is, , a, , test"));
} }
public static Test suite () public static Test suite ()
@@ -1,5 +1,5 @@
// //
// $Id: SetFieldRuleTest.java,v 1.2 2001/12/13 01:31:23 mdb Exp $ // $Id: SetFieldRuleTest.java,v 1.3 2002/04/11 04:07:42 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -87,7 +87,7 @@ public class SetFieldRuleTest extends TestCase
fail("Parsing failed: " + e); fail("Parsing failed: " + e);
} }
assert(EXPECTED.equals(object.toString())); assertTrue(EXPECTED.equals(object.toString()));
} }
public static Test suite () public static Test suite ()