119 testQueue(new ArrayBlockingQueue<Object>(1,false));
120 testQueue(new ArrayBlockingQueue<Object>(1,true));
121 testQueue(new LinkedBlockingQueue<Object>(1));
122 testQueue(new LinkedBlockingDeque<Object>(1));
123 }
124
125 //--------------------- Infrastructure ---------------------------
126 static volatile int passed = 0, failed = 0;
127 static void pass() {passed++;}
128 static void fail() {failed++; Thread.dumpStack();}
129 static void fail(String msg) {System.out.println(msg); fail();}
130 static void unexpected(Throwable t) {failed++; t.printStackTrace();}
131 static void check(boolean cond) {if (cond) pass(); else fail();}
132 static void equal(Object x, Object y) {
133 if (x == null ? y == null : x.equals(y)) pass();
134 else fail(x + " not equal to " + y);}
135 public static void main(String[] args) throws Throwable {
136 try {realMain(args);} catch (Throwable t) {unexpected(t);}
137 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
138 if (failed > 0) throw new AssertionError("Some tests failed");}
139 private static abstract class Fun {abstract void f() throws Throwable;}
140 }
|
119 testQueue(new ArrayBlockingQueue<Object>(1,false));
120 testQueue(new ArrayBlockingQueue<Object>(1,true));
121 testQueue(new LinkedBlockingQueue<Object>(1));
122 testQueue(new LinkedBlockingDeque<Object>(1));
123 }
124
125 //--------------------- Infrastructure ---------------------------
126 static volatile int passed = 0, failed = 0;
127 static void pass() {passed++;}
128 static void fail() {failed++; Thread.dumpStack();}
129 static void fail(String msg) {System.out.println(msg); fail();}
130 static void unexpected(Throwable t) {failed++; t.printStackTrace();}
131 static void check(boolean cond) {if (cond) pass(); else fail();}
132 static void equal(Object x, Object y) {
133 if (x == null ? y == null : x.equals(y)) pass();
134 else fail(x + " not equal to " + y);}
135 public static void main(String[] args) throws Throwable {
136 try {realMain(args);} catch (Throwable t) {unexpected(t);}
137 System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
138 if (failed > 0) throw new AssertionError("Some tests failed");}
139 private abstract static class Fun {abstract void f() throws Throwable;}
140 }
|