Exemplo n.º 1
0
#include "easypng.h"
#include "proxy.h"
#include "quadtree.h"

using namespace std;
using namespace util;

#if MP_PART(1)

// test constructor, decompress
UNIT_TEST(test_outHalf, 5, 2, 1000)
{
	PNG imgIn("in.png");

	Quadtree halfTree(imgIn, 128);
	PNG imgOut = halfTree.decompress();

	PNG imgSoln("soln_outHalf.png");
	ASSERT(imgOut == imgSoln);
	PASS;
}

#endif

#if MP_PART(2)

UNIT_TEST(test_pruneSize, 0, 1, 1000)
{
	PNG imgIn("in.png");
	Quadtree fullTree;
	fullTree.buildTree(imgIn, 256);
Exemplo n.º 2
0
int main() {

   PNG imgIn, imgOut;
   imgIn.readFromFile("in.png");

   // test constructor, decompress
   Quadtree halfTree(imgIn, 128);
   imgOut = halfTree.decompress();
   imgOut.writeToFile("outHalf.png");

   // now for the real tests
   Quadtree fullTree;
   fullTree.buildTree(imgIn, 256);

   // you may want to experiment with different commands in this section

   // test pruneSize and idealPrune (slow in valgrind, so you may want to
   // comment these out when doing most of your testing for memory leaks)
   cout << "fullTree.pruneSize(0) = " << fullTree.pruneSize(0) << endl;
   cout << "fullTree.pruneSize(100) = " << fullTree.pruneSize(100) << endl;
   cout << "fullTree.pruneSize(1000) = " << fullTree.pruneSize(1000) << endl;
   cout << "fullTree.pruneSize(100000) = " << fullTree.pruneSize(100000) << endl;

   cout << "fullTree.idealPrune(1000) = "  << fullTree.idealPrune(1000) << endl;
   cout << "fullTree.idealPrune(10000) = " << fullTree.idealPrune(10000) << endl;


   // Test some creation/deletion functions
   Quadtree fullTree2;
   fullTree2 = fullTree;
   imgOut = fullTree2.decompress();
   imgOut.writeToFile("outCopy.png");


   //test clockwiseRotate
   fullTree.clockwiseRotate();
   imgOut = fullTree.decompress();
   imgOut.writeToFile("outRotated.png");


   // test prune
   fullTree = fullTree2;
   fullTree.prune(1000);
   imgOut = fullTree.decompress();
   imgOut.writeToFile("outPruned.png");


   // test several functions in succession
   Quadtree fullTree3(fullTree2);
   fullTree3.clockwiseRotate();
   fullTree3.prune(10000);
   fullTree3.clockwiseRotate();
   fullTree3.clockwiseRotate();
   fullTree3.clockwiseRotate();
   imgOut = fullTree3.decompress();
   imgOut.writeToFile("outEtc.png");

   // ensure that printTree still works
   Quadtree tinyTree(imgIn, 32);
   cout << "Printing tinyTree:\n";
   tinyTree.prune(100);
   tinyTree.printTree();

   return 0;
}