1 /******************************************************************************* 2 * SAT4J: a SATisfiability library for Java Copyright (C) 2004, 2012 Artois University and CNRS 3 * 4 * All rights reserved. This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License v1.0 6 * which accompanies this distribution, and is available at 7 * http://www.eclipse.org/legal/epl-v10.html 8 * 9 * Alternatively, the contents of this file may be used under the terms of 10 * either the GNU Lesser General Public License Version 2.1 or later (the 11 * "LGPL"), in which case the provisions of the LGPL are applicable instead 12 * of those above. If you wish to allow use of your version of this file only 13 * under the terms of the LGPL, and not to allow others to use your version of 14 * this file under the terms of the EPL, indicate your decision by deleting 15 * the provisions above and replace them with the notice and other provisions 16 * required by the LGPL. If you do not delete the provisions above, a recipient 17 * may use your version of this file under the terms of the EPL or the LGPL. 18 * 19 * Based on the original MiniSat specification from: 20 * 21 * An extensible SAT solver. Niklas Een and Niklas Sorensson. Proceedings of the 22 * Sixth International Conference on Theory and Applications of Satisfiability 23 * Testing, LNCS 2919, pp 502-518, 2003. 24 * 25 * See www.minisat.se for the original solver in C++. 26 * 27 * Contributors: 28 * CRIL - initial API and implementation 29 *******************************************************************************/ 30 package org.sat4j.minisat.core; 31 32 import junit.framework.TestCase; 33 34 /* 35 * Created on 23 oct. 2003 36 * 37 * To change the template for this generated file go to 38 * Window>Preferences>Java>Code Generation>Code and Comments 39 */ 40 41 /** 42 * @author leberre 43 * 44 * To change the template for this generated type comment go to 45 * Window>Preferences>Java>Code Generation>Code and Comments 46 */ 47 public class QueueTest extends TestCase { 48 49 /** 50 * Constructor for QueueTest. 51 * 52 * @param arg0 53 */ 54 public QueueTest(String arg0) { 55 super(arg0); 56 } 57 58 /* 59 * @see TestCase#setUp() 60 */ 61 @Override 62 protected void setUp() throws Exception { 63 this.qu = new IntQueue(); 64 } 65 66 public void testInsert() { 67 this.qu.ensure(15); 68 for (int i = 0; i < 15; i++) { 69 this.qu.insert(i); 70 } 71 for (int i = 0; i < 15; i++) { 72 assertEquals(i, this.qu.dequeue()); 73 } 74 } 75 76 public void testDequeue() { 77 this.qu.insert(1); 78 this.qu.insert(2); 79 assertEquals(2, this.qu.size()); 80 int i = this.qu.dequeue(); 81 assertEquals(1, i); 82 this.qu.insert(3); 83 assertEquals(2, this.qu.size()); 84 i = this.qu.dequeue(); 85 assertEquals(2, i); 86 i = this.qu.dequeue(); 87 assertEquals(3, i); 88 } 89 90 public void testClear() { 91 assertEquals(0, this.qu.size()); 92 this.qu.insert(1); 93 this.qu.insert(2); 94 assertEquals(2, this.qu.size()); 95 this.qu.clear(); 96 assertEquals(0, this.qu.size()); 97 this.qu.insert(1); 98 this.qu.insert(2); 99 assertEquals(2, this.qu.size()); 100 } 101 102 public void testSize() { 103 assertEquals(0, this.qu.size()); 104 this.qu.insert(1); 105 assertEquals(1, this.qu.size()); 106 this.qu.insert(2); 107 assertEquals(2, this.qu.size()); 108 this.qu.dequeue(); 109 assertEquals(1, this.qu.size()); 110 this.qu.dequeue(); 111 assertEquals(0, this.qu.size()); 112 } 113 114 private IntQueue qu; 115 116 }