< prev index next > test/jdk/java/util/Collections/AsLifoQueue.java
Print this page
/*
! * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
/*
! * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
/*
* @test
* @bug 6301085 6192552 6365601
* @summary Basic tests for asLifoQueue
* @author Martin Buchholz
+ * @library /test/lib
*/
+ import jdk.test.lib.valueclass.VClass;
import java.util.*;
import java.util.concurrent.*;
public class AsLifoQueue {
check(q.isEmpty());
equal(q.size(), 0);
} catch (Throwable t) { unexpected(t); }
THROWS(NullPointerException.class, () -> Collections.asLifoQueue(null));
+
+ try {
+ Deque<VClass> deq = new ArrayDeque<>();
+ Queue<VClass> q = Collections.asLifoQueue(deq);
+ check(q.add(new VClass(1, new int[] { 1 })));
+ check(q.add(new VClass(2, new int[] { 2 })));
+ equal(q.peek(), new VClass(2, new int[] { 2 }));
+ equal(q.remove(), new VClass(2, new int[] { 2 }));
+ equal(q.poll(), new VClass(1, new int[] { 1 }));
+ check(q.isEmpty());
+ } catch (Throwable t) { unexpected(t); }
}
//--------------------- Infrastructure ---------------------------
static volatile int passed = 0, failed = 0;
static void pass() {passed++;}
< prev index next >