Пример #1
0
TEST(insert, stringTest) {
    int r = 10;
    int c = 10;
    TwoDArray<string>* a = new TwoDArray<string>(r, c);
    a->insert(0, 0, "hey");
    a->insert(0, 9, "whats");
    a->insert(9, 9, "up");
    a->insert(4, 4, "yooooooooooo");
    delete a;
}
Пример #2
0
TEST(insert, integerTest) {
    int r = 10;
    int c = 10;
    TwoDArray<int>* a = new TwoDArray<int>(r, c);
    a->insert(0, 0, 400);
    a->insert(0, 9, 900);
    a->insert(9, 9, 92939);
    a->insert(4, 4, 567658);
    delete a;
}
Пример #3
0
TEST(insert, doubleTest) {
    int r = 10;
    int c = 10;
    TwoDArray<double>* a = new TwoDArray<double>(r, c);
    a->insert(0, 0, 4089.7678);
    a->insert(0, 9, 900.435468);
    a->insert(9, 9, 92939.765);
    a->insert(4, 4, 567658.12);
    delete a;
}
Пример #4
0
TEST(TwoDArray, Print) {
	TwoDArray<int>* newArray = new TwoDArray<int>(10,10,0);
	newArray->insert(1,2,1);
	newArray->insert(9,8,2);
	newArray->insert(7,2,3);
	newArray->insert(6,4,4);
	newArray->insert(0,8,5);
	newArray->print();
	delete newArray;
}
Пример #5
0
TEST(TwoDArrayTest, insert) {
  TwoDArray<int>* td = new TwoDArray<int>(10, 10, 0);
  td->insert(5, 4, 10);
  td->insert(5, 5, 9);
  td->insert(5, 6, 8);


  EXPECT_EQ(10, td->access(5, 4));
  EXPECT_EQ(8, td->access(5, 6));
  delete td;
}
Пример #6
0
TEST(TwoDArrayTest, access) {
  TwoDArray<int>* td = new TwoDArray<int>(100, 100, 42);
  td->insert(25, 25, 1);
  td->insert(25, 26, 2);
  td->insert(26, 25, 3);
  td->insert(26, 26, 4);
  
  EXPECT_EQ(42, td->access(0, 0));
  EXPECT_EQ(4, td->access(26, 26));
  delete td;
}
Пример #7
0
TEST(TwoDArray, Insert) {
	TwoDArray<int>* newInt = new TwoDArray<int>(10,10,0);
	newInt->insert(5,5,5);
	EXPECT_EQ(5, newInt->access(5,5));
	delete newInt;

	TwoDArray<std::string>* newString = new TwoDArray<std::string>(10,10,"null");
	newString->insert(5,5,"yo");
	EXPECT_EQ("yo", newString->access(5,5));
	delete newString;

	TwoDArray<double>* newDouble = new TwoDArray<double>(10,10,0.0);
	newDouble->insert(5,5,5.5);
	EXPECT_EQ(5.5, newDouble->access(5,5));
	delete newDouble;
}
Пример #8
0
TEST(TwoDArrayTest, InsertInt) {
    TwoDArray<int>* tDInt = new TwoDArray<int>(3, 3, 0);
    for (int i=0; i < 3; i++) {
	  tDInt->insert(i, i, 3);
    }
    EXPECT_EQ(3, tDInt->access(1, 1));
    delete tDInt;
}
Пример #9
0
TEST(access, stringTest) {
    int r = 10;
    int c = 10;
    TwoDArray<string>* a = new TwoDArray<string>(r, c);
    a->insert(9, 9, "yarrr");
    EXPECT_EQ("yarrr", a->access(9, 9));
    delete a;
}
Пример #10
0
TEST(access, doubleTest) {
    int r = 10;
    int c = 10;
    TwoDArray<double>* a = new TwoDArray<double>(r, c);
    a->insert(5, 4, 423.633);
    EXPECT_EQ(423.633, a->access(5, 4));
    delete a;
}
Пример #11
0
TEST(arrayTest, getNumRows) {
  TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
  TwoDArray<double>* d = new TwoDArray<int>(6, 5, 0);
  TwoDArray<std::string>* s = new TwoDArray<std::string>(10, 5, "o");

  i->insert(2, 2, 7);
  d->insert(4, 4, 3.145);
  s->insert(0, 0, "Hello");

  EXPECT_EQ(5, i->getNumRows());
  EXPECT_EQ(6, d->getNumRows());
  EXPECT_EQ(10, s->getNumRows());

  delete i;
  delete d;
  delete s;
}
Пример #12
0
void AVLTree<T>::visualPrint(T def, T leftLeg, T rightLeg) {
	
	//make a Queue of globs, push in root at 0, 0
	list<Glob<T>*> q;
	int level=0; int spread=0;
	Glob<T>* root_glob = new Glob<T>(*root, level, spread);
	q.push_back (root_glob);
	
	//make 2d vector for glob coordinates, spread is width, level is depth
	int s; int l;
	TwoDArray<T>* tda = new TwoDArray<T>(8, 15, def);
	int spread_middle = 7;
	
	//begin level order traversal of AVLTree and insert into tda
	Node<T>* curr_node;
	while (!(q.empty())) {
		Glob<T>* curr_glob = q.front();
		curr_node = curr_glob->getNodePointer();
		if (curr_node->getLeftChild()!=0) {
			//get level, spread for left node and make a glob
			level = (curr_glob->getLevel())+2;
			spread = (curr_glob->getSpread())-2;
			Glob<T>* new_glob_left = new Glob<T>(*(curr_node->getLeftChild()), level, spread);
			q.push_back (new_glob_left);
			//insert left leg into tda
			tda->insert(level-1, spread_middle+spread+1, leftLeg);
		}
		if (curr_node->getRightChild()!=0) {
			level=(curr_glob->getLevel())+2;
			spread = (curr_glob->getSpread())+2;
			Glob<T>* new_glob_right = new Glob<T>(*(curr_node->getRightChild()), level, spread);
			q.push_back (new_glob_right);
			//insert right leg tda
			tda->insert(level-1, spread_middle+spread-1, rightLeg);			
		}		
		if (curr_node!=0) {
			l = curr_glob->getLevel();
			s = curr_glob->getSpread();
			tda->insert(l, spread_middle+s, curr_glob->getNodePointer()->getValue());
		}
		q.pop_front();	
	}
	tda->print();
	delete tda;
	delete root_glob;
}
Пример #13
0
TEST(access, integerTest) {
    int r = 10;
    int c = 10;
    TwoDArray<int>* a = new TwoDArray<int>(r, c);
    a->insert(0, 0, 400);
    EXPECT_EQ(400, a->access(0, 0));
    delete a;
}
Пример #14
0
TEST(arrayTest, insert) {
  TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
  TwoDArray<double>* d = new TwoDArray<int>(5, 5, 0);
  TwoDArray<std::string>* s = new TwoDArray<std::string>(5, 5, "o");

  i->insert(2, 2, 7);
  d->insert(4, 4, 3.145);
  s->insert(0, 0, "Hello");

  EXPECT_EQ(7, i->access(2, 2));
  EXPECT_EQ(3.145, d->access(4, 4));
  EXPECT_EQ("Hello", s->access(0, 0));

  delete i;
  delete d;
  delete s;
}
Пример #15
0
TEST(TwoDArrayTest, remove) {
  TwoDArray<int>* td = new TwoDArray<int>(10, 10, 42);
  td->insert(5, 5, 12);
  
  td->remove(5, 5);
  EXPECT_EQ(42, td->access(5,5));
  delete td;
}
Пример #16
0
int main(){

	TwoDArray<int>* newArray = new TwoDArray<int>(10, 10, 0);

	newArray->insert(1,1,5);
	cout << newArray->access(1,1) << endl;
	newArray->remove(1,1);
	cout << newArray->access(1,1) << endl;
	newArray->print();
	delete newArray;

	TwoDArray<std::string>* nextArray = new TwoDArray<std::string>(5,5, "hi");
	nextArray->insert(2,2, "bye");
	nextArray->print();
	delete nextArray;

}
Пример #17
0
TEST(remove, integerTest) {
    int r = 10;
    int c = 10;
    TwoDArray<int>* a = new TwoDArray<int>(r, c);
    a->insert(0, 0, 400);
    a->remove(0, 0);
    ASSERT_TRUE(a->access(0, 0) != 400);
    delete a;
}
Пример #18
0
TEST(TwoDArray, PrintInt) {
    TwoDArray<int>* tdInt = new TwoDArray<int>(5, 5, 0);
    for (int i = 0; i < 5; i++) {
	  tdInt->insert(i, i, 7);
    }
    std::cout << "TDArray Integer print" << std::endl;
    tdInt->print();
    delete tdInt;
}
Пример #19
0
TEST(TwoDArrayTest, InsertStirng) {
    TwoDArray<string>* tDString = new TwoDArray<string>(3, 3, "default");

    for (int i=0; i < 3; i++) {
	  tDString->insert(i, i, "Integer");
    }
    EXPECT_EQ("Integer", tDString->access(1, 1));
    delete tDString;
}
Пример #20
0
TEST(TwoDArray, PrintString) {
    TwoDArray<string>* tdS = new TwoDArray<string>(5, 5, "default");
    for (int i = 0; i < 5; i++) {
	  tdS->insert(i, i, "hello");
    }
    std::cout << "TDArray String print" << std::endl;
    tdS->print();
    delete tdS;
}
Пример #21
0
TEST(TwoDArray, PrintDouble) {
    TwoDArray<double>* tdD = new TwoDArray<double>(5, 5, 0.00);
    for (int i = 0; i < 5; i++) {
	  tdD->insert(i, i, 7.77);
    }
    std::cout << "TDArray Double print" << std::endl;
    tdD->print();
    delete tdD;
}
Пример #22
0
TEST(TwoDArrayTest, InsertDoulbe) {
    TwoDArray<double>* tDDouble = new TwoDArray<double>(3, 3, 0.0);

    for (int i=0; i < 3; i++) {
	  tDDouble->insert(i, i, 3.3);
    }
    EXPECT_EQ(3.3, tDDouble->access(1, 1));
    delete tDDouble;
}
Пример #23
0
TEST(TwoDArray, Access) {
	TwoDArray<int>* newInt = new TwoDArray<int>(24,67,5);
	EXPECT_EQ(5, newInt->access(10,10));
	newInt->insert(15,17,100);
	EXPECT_EQ(100, newInt->access(15,17));
	delete newInt;

	TwoDArray<double>* newDouble = new TwoDArray<double>(33,54,5.6);
	EXPECT_EQ(5.6, newDouble->access(12,24));
	newDouble->insert(13,15,7.8);
	EXPECT_EQ(7.8, newDouble->access(13,15));
	delete newDouble;
	
	TwoDArray<std::string>* newString = new TwoDArray<std::string>(20,20,"null");
	EXPECT_EQ("null", newString->access(10,10));
	newString->insert(15,17,"howdy");
	EXPECT_EQ("howdy", newString->access(15,17));
	delete newString;
}
Пример #24
0
TEST(TwoDArray, Remove) {
	TwoDArray<int>* newInt = new TwoDArray<int>(5,5,0);
	newInt->insert(2,3,4);
	newInt->remove(2,3);
	EXPECT_EQ(0, newInt->access(2,3));
	delete newInt;

	TwoDArray<double>* newDouble = new TwoDArray<double>(3,4,1.0);
	newDouble->insert(2,1,4.4);
	newDouble->remove(2,1);
	EXPECT_EQ(1.0, newDouble->access(2,3));
	delete newDouble;

	TwoDArray<std::string>* newString = new TwoDArray<std::string>(100,200,"empty");
	newString->insert(48, 68, "hello");
	newString->remove(2,3);
	EXPECT_EQ("hello", newString->access(48,68));
	delete newString;
}
Пример #25
0
TEST(remove, doubleTest) {
    int r = 10;
    int c = 10;
    TwoDArray<double>* a = new TwoDArray<double>(r, c);
    a->insert(9, 9, 400.2);
    a->remove(9, 9);
    double d;
    ASSERT_TRUE(a->access(0, 0) != 400.2);
    delete a;
}
Пример #26
0
TEST(TwoDArrayRemove, RemoveInt) {
    TwoDArray<int>* tDInt = new TwoDArray<int>(10, 10, 0);
    
    for (int i=0; i<10; i++) {
	  tDInt->insert(i, i, 7);
    }
    tDInt->remove(7, 5);
    EXPECT_EQ(0, tDInt->access(7, 5));
    delete tDInt;
}
Пример #27
0
TEST(arrayTest, print) {
  TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
  TwoDArray<double>* d = new TwoDArray<int>(5, 5, 0);
  TwoDArray<std::string>* s = new TwoDArray<std::string>(5, 5, "o");

  i->insert(2, 2, 7);
  d->insert(4, 4, 3.145);
  s->insert(0, 0, "Hello");

  i->print();
  std::cout << std::endl;
  d->print();
  std::cout << std::endl;
  s->print();

  delete i;
  delete d;
  delete s;
}
Пример #28
0
TEST(remove, stringTest) {
    int r = 10;
    int c = 10;
    TwoDArray<string>* a = new TwoDArray<string>(r, c);
    a->insert(5, 4, "yay");
    a->remove(5, 4);
    string d;
    ASSERT_TRUE(a->access(0, 0) != "yay");
    delete a;
}
Пример #29
0
TEST(TwoDArrayRemove, RemoveDouble) {
    TwoDArray<double>* tDDouble = new TwoDArray<double>(10, 10, 0.0);
    
    for (int i=0; i<10; i++) {
	  tDDouble->insert(i, i, 7);
    }
    tDDouble->remove(7, 5);
    EXPECT_EQ(0.0, tDDouble->access(7, 5));
    delete tDDouble;
}
Пример #30
0
Test(arrayTest, remove) {
  TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
  TwoDArray<double>* d = new TwoDArray<int>(5, 5, 0);
  TwoDArray<std::string>* s = new TwoDArray<std::string>(5, 5, "o");
  
  i->insert(2, 2, 7);
  d->insert(4, 4, 3.145);
  s->insert(0, 0, "Hello");
  i->insert(3, 3, 9);
  
  i->remove(2, 2);
  d->remove(4, 4);
  s->remove(0, 0);

  s->insert(0, 0, "y");

  EXPECT_EQ(0, i->access(2, 2));
  EXPECT_EQ(0, d->access(4, 4));
  EXPECT_EQ("y", s->access(0, 0));
  EXPECT_EQ(9, i->insert(3, 3));

  delete i;
  delete d;
  delete s;
}