Homework 1 Test Data

Homework 1 Test Data - Homework 1 Test Data As the syllabus...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 1 Test Data As the syllabus said, not every problem of every homework will necessarily be graded. For this homework, we primarily graded problems 3 and 5, although you lost 20 points if your StudentMultiset in Problem 4 was not implemented using a Multiset as required, delegating as much work as possible to that Multiset. A number of people lost additional points for not meeting the requirements listed under "Turn it in" in the spec. When the following program is compiled along with Multiset.cpp, it can be run with input 1 through 53 to test your solution to Problem 3. If the #define of TESTNEW is uncommented and the program is compiled along with newMultiset.cpp, it can be run with input 1 through 66 to test your solution to Problem 5. (This program uses some features of C++ we're not covering, but that's irrelevant to you.) Each passed test was worth 80/119 point. // tester.cpp // To test HW 1 Problem 5, uncomment the following line: // #define TESTNEW #ifdef TESTNEW #include "newMultiset.h" #else #include "Multiset.h" #endif #include <iostream> #include <cstdlib> #include <cassert> #include <string> using namespace std; bool emptytype(bool (Multiset::*)() const) { return true; } bool emptytype(bool (Multiset::*)()) { return false; } bool emptytype(. ..) { return false; } bool sizetype(int (Multiset::*)() const) { return true; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
bool sizetype(int (Multiset::*)()) { return false; } bool sizetype(. ..) { return false; } bool uniqueSizetype(int (Multiset::*)() const) { return true; } bool uniqueSizetype(int (Multiset::*)()) { return false; } bool uniqueSizetype(. ..) { return false; } bool containstype(bool (Multiset::*)(const ItemType&) const) { return true; } bool containstype(bool (Multiset::*)(const ItemType&)) { return false; } bool containstype(. ..) { return false; } bool counttype(int (Multiset::*)(const ItemType&) const) { return true; } bool counttype(int (Multiset::*)(const ItemType&)) { return false; } bool counttype(. ..) { return false; } bool gettype(int (Multiset::*)(int, ItemType&) const) { return true; } bool gettype(int (Multiset::*)(int, ItemType&)) { return false; } bool gettype(. ..) { return false; } ItemType DUMMY = 123; ItemType DEFAULT = 0; ItemType ARRAY[6] = { 10, 20, 30, 40, 50, 60 }; bool isPermutation(ItemType a[], const ItemType b[], int n) { for (size_t k = 0; k < n; k++) { size_t j; for (j = k; j < n; j++) { if (b[k] == a[j]) { ItemType t = a[k]; a[k] = a[j]; a[j] = t; break; } } if (j == n) return false;
Background image of page 2
} return true; } const int SPEC_MAX = 200; void testone(int n) { Multiset ms; switch (n) { default: { cout << "Bad argument" << endl; } break; case 1: { assert(emptytype(&Multiset::empty)); } break; case 2: { assert(sizetype(&Multiset::size)); } break; case 3: { assert(uniqueSizetype(&Multiset::uniqueSize)); } break; case 4: { assert(containstype(&Multiset::contains)); } break; case 5: { assert(counttype(&Multiset::count)); } break; case 6: {
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

Homework 1 Test Data - Homework 1 Test Data As the syllabus...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online