Skip to content

GitLab

  • Menu
    • Projects Groups Snippets
      Help
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • P project06
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cs2-23wi
  • project06
  • Merge requests
  • !2

An error occurred while fetching the assigned milestone of the selected merge_request.
Merged
Created 2 years ago by Winter Pearson@winterMaintainer

Adds messages to all assertions which were missing them

  • Overview 0
  • Commits 2
  • Pipelines 2
  • Changes 3
  • James C Bowden @jbowden added 1 commit 2 years ago

    added 1 commit

    • d9f4e4e2 - remove brittle test graphs (re. sarah)

    Compare with previous version

  • James C Bowden @jbowden mentioned in commit 0ec4c805 2 years ago

    mentioned in commit 0ec4c805

  • James C Bowden @jbowden merged 2 years ago

    merged

  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
Compare
  • version 1
    5b251ca7
    2 years ago

  • master (base)

and
  • latest version
    d9f4e4e2
    2 commits, 2 years ago

  • version 1
    5b251ca7
    1 commit, 2 years ago

3 files
+ 50
- 34

    Preferences

    File browser
    Compare changes
tests/edu/‎caltech/cs2‎
datastr‎uctures‎
MinFourHea‎pTests.java‎ +34 -23
proj‎ect06‎
DSaturTe‎sts.java‎ +11 -9
ProgramT‎ests.java‎ +5 -2
tests/edu/caltech/cs2/datastructures/MinFourHeapTests.java
+ 34
- 23
  • View file @ d9f4e4e2

  • Edit in single-file editor

  • Edit in Web IDE


Show all unchanged lines Show 20 lines
// enqueue values while examining internal state
for (int i = 0; i < values.size(); i++) {
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(values.get(i), values.get(i))));
assertEquals(i + 1, heap.size());
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(values.get(i), values.get(i))),
"Enqueue unexpectedly returned false.");
assertEquals(i + 1, heap.size(), "Enqueue did not update size as appropriate.");
IPriorityQueue.PQElement<Integer>[] heapData = Reflection.getFieldValue(MinFourHeap.class, "data", heap);
for (int j = 0; j < heap.size(); j++) {
assertEquals(step_by_step.get(i).toArray()[j], heapData[j].data);
assertEquals(step_by_step.get(i).toArray()[j], heapData[j].data,
"Heap structure after enqueue is incorrect.");
}
checkKeyToIndexMap(heap);
Show 20 lines Show all unchanged lines Show 20 lines
PriorityQueue<Integer> reference = new PriorityQueue<>(c);
List<Integer> values = new ArrayList<>(Arrays.asList(9, -100, 19, 3, -2, 1, 7, -84, -4, 2, 70));
for (int value : values) {
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)));
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)),
"Enqueue unexpectedly returned false.");
reference.add(value);
}
for (int i = 0; i < reference.size(); i++) {
assertEquals(reference.remove(), heap.dequeue().data);
assertEquals(reference.remove(), heap.dequeue().data, "Dequeuing returned the incorrect value.");
checkKeyToIndexMap(heap);
assertEquals(reference.size(), heap.size());
assertEquals(reference.size(), heap.size(), "Dequeuing did not update size as appropriate.");
}
}
Show 20 lines Show all unchanged lines Show 20 lines
MinFourHeap<Integer> heap = new MinFourHeap<>();
List<Integer> values = new ArrayList<>(Arrays.asList(9, -100, 19, 3, -2, 1, 7, -84, -4, 2, 70));
for (Integer value : values) {
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)));
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)),
"Enqueuing unexpectedly returned false.");
}
// Assert constructed heap is correct
Integer[] correctHeapData = {-100, -84, 2, 3, -2, 9, 7, 1, -4, 19, 70};
IPriorityQueue.PQElement<Integer>[] heapData = Reflection.getFieldValue(MinFourHeap.class, "data", heap);
for (int j = 0; j < heap.size(); j++) {
assertEquals(correctHeapData[j], heapData[j].data);
assertEquals(correctHeapData[j], heapData[j].data, "Heap structure after enqueue is incorrect.");
}
// Increase the root's priority
heap.increaseKey(new IPriorityQueue.PQElement<>(-100, 100));
Show 20 lines Show all unchanged lines Show 20 lines
heapData = Reflection.getFieldValue(MinFourHeap.class, "data", heap);
checkKeyToIndexMap(heap);
for (int i = 0; i < heap.size(); i++) {
assertEquals(correctHeapPrioritiesAfterIncrease[i], heapData[i].priority);
assertEquals(correctHeapPrioritiesAfterIncrease[i], heapData[i].priority,
"Priorities or layout after increaseKey is incorrect.");
}
}
Show 20 lines Show all unchanged lines Show 20 lines
MinFourHeap<Integer> heap = new MinFourHeap<>();
List<Integer> values = new ArrayList<>(Arrays.asList(9, -100, 19, 3, -2, 1, 7, -84, -4, 2, 70));
for (Integer value : values) {
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)));
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)),
"Enqueuing unexpectedly returned false.");
}
// Assert constructed heap is correct
Integer[] correctHeapData = {-100, -84, 2, 3, -2, 9, 7, 1, -4, 19, 70};
IPriorityQueue.PQElement<Integer>[] heapData = Reflection.getFieldValue(MinFourHeap.class, "data", heap);
for (int j = 0; j < heap.size(); j++) {
assertEquals(correctHeapData[j], heapData[j].data);
assertEquals(correctHeapData[j], heapData[j].data, "Heap structure after enqueue is incorrect.");
}
// Decrease some node's priority
heap.decreaseKey(new IPriorityQueue.PQElement<>(7, -105));
Show 20 lines Show all unchanged lines Show 20 lines
heapData = Reflection.getFieldValue(MinFourHeap.class, "data", heap);
checkKeyToIndexMap(heap);
for (int i = 0; i < heap.size(); i++) {
assertEquals(correctHeapPrioritiesAfterDecrease[i], heapData[i].priority);
assertEquals(correctHeapPrioritiesAfterDecrease[i], heapData[i].priority,
"Priorities or layout after decreaseKey is incorrect.");
}
}
Show 20 lines Show all unchanged lines Show 20 lines
MinFourHeap<Integer> heap = new MinFourHeap<>();
List<Integer> values = new ArrayList<>(Arrays.asList(1, 6, 7, 8, 2));
for (int value : values) {
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)));
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)),
"Enqueuing unexpectedly returned false.");
}
// Dequeueing 1 won't cause any further percolations, since 2 is in the right place.
// There's some edge cases around this for some reason, which is why the test is here...
assertEquals(1, heap.dequeue().data);
assertEquals(1, heap.dequeue().data,
"Dequeuing unexpectedly rearranged the heap.");
checkKeyToIndexMap(heap);
}
Show 20 lines Show all unchanged lines Show 20 lines
// 0 => [2 => [5, 6, 7, 8], 1 => [9], 3 => [], 4 => []]
List<Integer> values = new ArrayList<>(Arrays.asList(0, 2, 1, 3, 4, 5, 6, 7, 8, 9));
for (int value : values) {
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)));
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(value, value)),
"Enqueuing unexpectedly returned false.");
}
IPriorityQueue.PQElement<Integer>[] heapData = Reflection.getFieldValue(MinFourHeap.class, "data", heap);
// Make sure our heap data is still "good" for the test
assertEquals(10, heapData.length, "Heap data array is not a default size of 10 or was resized prematurely");
assertEquals(10, heapData.length, "Heap data array is not a default size of 10 or was resized prematurely.");
// Increase the node at the root. The node gets swapped with 1, then compared against children.
// But, 9 is at the last index in the heap array and not the last child.
Show 20 lines Show all unchanged lines Show 20 lines
}
reference.add(num);
heap.enqueue(new IPriorityQueue.PQElement<>(num, num));
assertEquals(reference.size(), heap.size());
assertEquals(reference.size(), heap.size(), "Heap size after enqueue was incorrect.");
}
for (int j = 0; j < numToReplace; j++) {
Show 20 lines Show all unchanged lines Show 20 lines
} else {
heap.increaseKey(new IPriorityQueue.PQElement<>(origKey, newPriority));
}
assertEquals(reference.size(), heap.size());
assertEquals(reference.size(), heap.size(), "Heap size after adjusting priorities was incorrect.");
removed.add(origKey);
reference.remove(origKey);
reference.add(newPriority);
assertEquals(reference.size(), heap.size());
assertEquals(reference.size(), heap.size(), "Heap size after adjusting priorities was incorrect.");
}
int i = 0;
while (!reference.isEmpty()) {
Show 20 lines Show all unchanged lines Show 20 lines
System.err.println(reference.size());
System.err.println(heap.size());
}
assertEquals((double) er, mr.priority);
assertEquals((double) er, mr.priority, "Priorities after adjusting them and dequeuing were incorrect.");
i++;
}
}
Show 20 lines Show all unchanged lines Show 20 lines
num = r.nextInt();
}
reference.add(num);
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(num, num)));
assertTrue(heap.enqueue(new IPriorityQueue.PQElement<>(num, num)),
"Enqueuing unexpectedly returned false.");
// Check at intervals to save computation
if (i % 499 == 0) {
checkKeyToIndexMap(heap);
}
assertEquals(reference.size(), heap.size());
assertEquals(reference.size(), heap.size(), "Heap size after enqueuing was incorrect.");
}
while (heap.size() != 0) {
assertEquals(reference.remove(), heap.dequeue().data);
assertEquals(reference.remove(), heap.dequeue().data, "Dequeuing returned the wrong element.");
if (heap.size() % 499 == 0) {
checkKeyToIndexMap(heap);
Show 20 lines Show all unchanged lines
tests/edu/caltech/cs2/project06/DSaturTests.java
+ 11
- 9
  • View file @ d9f4e4e2

  • Edit in single-file editor

  • Edit in Web IDE


Show all unchanged lines Show 20 lines
if (myColor > maxColor) {
maxColor = myColor;
}
assertTrue(myColor > 0);
assertTrue(myColor > 0,
"All of the vertices in the graph must be colored when you're done.");
for (int neighbor : g.neighbors(i)) {
assertTrue(myColor != g.getColor(neighbor));
assertTrue(myColor != g.getColor(neighbor),
"Invalid coloring: two adjacent vertices share the same color.");
}
}
assertTrue(maxColor <= N, "" + maxColor + " is supposed to be <= " + N);
assertTrue(maxColor <= N, maxColor + " is supposed to be <= " + N);
}
private static record Pair<F, S>(F first, S second) {
Show 20 lines Show all unchanged lines Show 20 lines
"fpsol2.i.2.graph", "fpsol2.i.3.graph", "games120.graph",
"homer.graph", "huck.graph", "inithx.i.1.graph",
"inithx.i.2.graph", "inithx.i.3.graph", "jean.graph",
"le450_15a.graph", "le450_15b.graph", "le450_15c.graph",
"le450_15d.graph", "le450_25a.graph", "le450_25b.graph",
"le450_15a.graph", "le450_15c.graph",
"le450_25a.graph", "le450_25b.graph",
"le450_25c.graph", "le450_25d.graph", "le450_5a.graph",
"le450_5b.graph", "le450_5c.graph", "le450_5d.graph",
"le450_5b.graph", "le450_5d.graph",
"miles1000.graph", "miles1500.graph", "miles250.graph",
"miles500.graph", "miles750.graph", "mulsol.i.1.graph",
"mulsol.i.2.graph", "mulsol.i.3.graph", "mulsol.i.4.graph",
"mulsol.i.5.graph", "myciel2.graph", "myciel3.graph",
"myciel4.graph", "myciel5.graph", "myciel6.graph",
"myciel7.graph", "queen10_10.graph", "queen11_11.graph",
"queen12_12.graph", "queen13_13.graph",
"queen15_15.graph", "queen16_16.graph", "queen5_5.graph",
"queen12_12.graph",
"queen16_16.graph", "queen5_5.graph",
"queen6_6.graph", "queen7_7.graph", "queen8_12.graph",
"queen8_8.graph", "queen9_9.graph", "school1.graph",
"queen8_8.graph", "school1.graph",
"school1_nsh.graph", "zeroin.i.1.graph", "zeroin.i.2.graph",
"zeroin.i.3.graph"})
public void testCmuGraphs(String fname) {
Show 20 lines Show all unchanged lines
tests/edu/caltech/cs2/project06/ProgramTests.java
+ 5
- 2
  • View file @ d9f4e4e2

  • Edit in single-file editor

  • Edit in Web IDE


Show all unchanged lines Show 20 lines
NodeGraph interference = program.constructInterferenceGraph();
DSatur.color(interference);
Program modified = program.color(interference.getColoring());
assertTrue(modified.variables().size() <= maxColors);
assertIterableEquals(interpret(program), interpret(modified));
assertTrue(modified.variables().size() <= maxColors,
"Interference graph coloring uses more colors than expected " +
"(ie: more variables were connected by edges than expected).");
assertIterableEquals(interpret(program), interpret(modified), "Interference graph does not validly "
+ " reflect interferences (ie: the resulting program overwrites its own variables).");
}
@Test
Show 20 lines Show all unchanged lines
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: assert

Menu

Projects Groups Snippets
Help