Commit 6c8c8c13 authored by Daniel Le Berre's avatar Daniel Le Berre
Browse files

New test case to make sure that the order is properly maintained. Thanks

STAMP.
parent 309b935d
Pipeline #3333 passed with stages
in 47 minutes and 17 seconds
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
*******************************************************************************/ *******************************************************************************/
package org.sat4j.minisat.core; package org.sat4j.minisat.core;
import junit.framework.TestCase;
import org.sat4j.minisat.orders.ActivityBasedVariableComparator; import org.sat4j.minisat.orders.ActivityBasedVariableComparator;
import junit.framework.TestCase;
public class HeapTest extends TestCase { public class HeapTest extends TestCase {
/* /*
...@@ -46,8 +46,8 @@ public class HeapTest extends TestCase { ...@@ -46,8 +46,8 @@ public class HeapTest extends TestCase {
* Test method for 'org.sat4j.minisat.core.Heap.inHeap(int)' * Test method for 'org.sat4j.minisat.core.Heap.inHeap(int)'
*/ */
public void testInHeap() { public void testInHeap() {
Heap heap = new Heap(new ActivityBasedVariableComparator(new double[] { Heap heap = new Heap(new ActivityBasedVariableComparator(
0.0, 3.0, 9.0, 2.0 })); new double[] { 0.0, 3.0, 9.0, 2.0 }));
heap.setBounds(5); heap.setBounds(5);
assertFalse(heap.inHeap(1)); assertFalse(heap.inHeap(1));
assertFalse(heap.inHeap(2)); assertFalse(heap.inHeap(2));
...@@ -83,15 +83,26 @@ public class HeapTest extends TestCase { ...@@ -83,15 +83,26 @@ public class HeapTest extends TestCase {
* Test method for 'org.sat4j.minisat.core.Heap.increase(int)' * Test method for 'org.sat4j.minisat.core.Heap.increase(int)'
*/ */
public void testIncrease() { public void testIncrease() {
double[] activity = new double[] { 0.0, 3.0, 6.0, 9.0 };
Heap heap = new Heap(new ActivityBasedVariableComparator(activity));
heap.setBounds(5);
heap.insert(1);
heap.insert(2);
heap.insert(3);
assertEquals(3, heap.getmin());
assertFalse(heap.inHeap(3));
heap.insert(3);
activity[2] = 12.0;
heap.increase(2);
assertEquals(2, heap.getmin());
} }
/* /*
* Test method for 'org.sat4j.minisat.core.Heap.empty()' * Test method for 'org.sat4j.minisat.core.Heap.empty()'
*/ */
public void testEmpty() { public void testEmpty() {
Heap heap = new Heap(new ActivityBasedVariableComparator( Heap heap = new Heap(
new double[] {})); new ActivityBasedVariableComparator(new double[] {}));
assertTrue(heap.empty()); assertTrue(heap.empty());
} }
...@@ -99,8 +110,8 @@ public class HeapTest extends TestCase { ...@@ -99,8 +110,8 @@ public class HeapTest extends TestCase {
* Test method for 'org.sat4j.minisat.core.Heap.insert(int)' * Test method for 'org.sat4j.minisat.core.Heap.insert(int)'
*/ */
public void testInsert() { public void testInsert() {
Heap heap = new Heap(new ActivityBasedVariableComparator(new double[] { Heap heap = new Heap(new ActivityBasedVariableComparator(
0.0, 1.0, 1.0, 2.0 })); new double[] { 0.0, 1.0, 1.0, 2.0 }));
heap.setBounds(5); heap.setBounds(5);
heap.insert(1); heap.insert(1);
heap.insert(2); heap.insert(2);
...@@ -114,8 +125,8 @@ public class HeapTest extends TestCase { ...@@ -114,8 +125,8 @@ public class HeapTest extends TestCase {
* Test method for 'org.sat4j.minisat.core.Heap.getmin()' * Test method for 'org.sat4j.minisat.core.Heap.getmin()'
*/ */
public void testGetmin() { public void testGetmin() {
Heap heap = new Heap(new ActivityBasedVariableComparator(new double[] { Heap heap = new Heap(new ActivityBasedVariableComparator(
0.0, 3.0, 9.0, 2.0 })); new double[] { 0.0, 3.0, 9.0, 2.0 }));
heap.setBounds(5); heap.setBounds(5);
heap.insert(1); heap.insert(1);
heap.insert(2); heap.insert(2);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment