예제 #1
0
Test(sparseTest, remove) {
  SparseArray<int>* i = new SparseArray<int>(5, 5, 0);
  SparseArray<double>* d = new SparseArray<int>(5, 5, 0);
  SparseArray<std::string>* s = new SparseArray<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;
}
예제 #2
0
TEST(SparseArrayAccess, AccessString) {
    SparseArray<string>* tDString = new SparseArray<string>(12, 12, "9");
    
    for (int i = 0; i < 10; i++) {
	  for(int j = 0; j < 10; j++) {
		tDString->access(i, j);
	  }
    }
    EXPECT_EQ("9", tDString->access(7, 7));
    delete tDString;
}
예제 #3
0
TEST(SparseArrayAccess, AccessDouble) {
    SparseArray<double>* tDDouble = new SparseArray<double>(11, 11, 8.8);
    
    for (int i = 0; i < 10; i++) {
	  for(int j = 0; j < 10; j++) {
		tDDouble->access(i, j);
	  }
    }
    EXPECT_EQ(8.8, tDDouble->access(7, 7));
    delete tDDouble;
}
예제 #4
0
TEST(SparseArrayAccess, AccessInt) {
    SparseArray<int>* tDInt = new SparseArray<int>(10, 10, 7);
    
    for (int i = 0; i < 10; i++) {
	  for(int j = 0; j < 10; j++) {
		tDInt->access(i, j);
	  }
    }
    EXPECT_EQ(7, tDInt->access(7, 7));
    delete tDInt;
}
예제 #5
0
//test insert into sparse array of int, double, string
TEST(Sparse, Insert) {
	SparseArray<int>* newInt= new SparseArray<int>(5,5,0);
	newInt->insert(0,0,5);
	EXPECT_EQ(5, newInt->access(0,0));
	delete newInt;

	SparseArray<double>* newDouble = new SparseArray<double>(5,6,0.0);
	newDouble->insert(2,4,6.5);
	EXPECT_EQ(6.5, newDouble->access(2,4));
	delete newDouble;
	
	SparseArray<std::string>* newString = new SparseArray<std::string>(7,8,"null");
	newString->insert(4,3,"howdy");
	EXPECT_EQ("howdy", newString->access(4,3));
	delete newString;
}
예제 #6
0
TEST(SparseArrayTest, InsertString) {
    SparseArray<string>* tDString = new SparseArray<string>(3, 3, "default");
    tDString->insert(1, 2, "Sparse");

    EXPECT_EQ("Sparse", tDString->access(1, 2));
    delete tDString;
}
예제 #7
0
TEST(sparseTest, access) {
  SparseArray<int>* i = new SparseArray<int>(5, 5, 0);
  SparseArray<double>* d = new SparseArray<int>(5, 5, 0);
  SparseArray<std::string>* s = new SparseArray<std::string>(5, 5, "World");
    
  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("World", s->access(2, 2));

  delete i;
  delete d;
  delete s;
}
예제 #8
0
TEST(SparseArrayTest, InsertDouble) {
    SparseArray<double>* tDDouble = new SparseArray<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;
}
예제 #9
0
TEST(SparseArrayRemove, RemoveString) {
    SparseArray<string>* tDString = new SparseArray<string>(10, 10, "default");
    for (int i=0; i<10; i++) {
	  tDString->insert(i, i, "HELLO");
    }
    tDString->remove(7, 5);
    EXPECT_EQ("default", tDString->access(7, 5));
    delete tDString;
}
예제 #10
0
TEST(SparseArrayTest, InsertInt) {
    SparseArray<int>* tDInt = new SparseArray<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;
}
예제 #11
0
TEST(Sparse, Remove) {
	SparseArray<int>* newSparse = new SparseArray<int>(5,5,0);
	newSparse->insert(0,0,4);
	newSparse->remove(0,0);
	EXPECT_EQ(0, newSparse->access(2,3));
	delete newSparse;

	SparseArray<double>* newDouble = new SparseArray<double>(5,7,0.0);
	newDouble->insert(2,3,4.9);
	newDouble->remove(2,3);
	EXPECT_EQ(0.0, newDouble->access(2,3));
	delete newDouble;

	SparseArray<std::string>* newString = new SparseArray<std::string>(321,678,"yes");
	newString->insert(2,3,"no");
	newString->remove(2,3);
	EXPECT_EQ("yes", newString->access(2,3));
	delete newString;
}
예제 #12
0
TEST(SparseArrayRemove, RemoveDouble) {
    SparseArray<double>* tDDouble = new SparseArray<double>(10, 10, 5.5);
    
    for (int i=0; i<10; i++) {
	  tDDouble->insert(i, i, 7.7);
    }
    tDDouble->remove(7, 5);
    EXPECT_EQ(5.5, tDDouble->access(7, 5));
    delete tDDouble;
}
예제 #13
0
TEST(SparseArrayRemove, RemoveInt) {
    SparseArray<int>* tDInt = new SparseArray<int>(10, 10, 5);
    
    for (int i=0; i<10; i++) {
	  tDInt->insert(i, i, 7);
    }
    tDInt->remove(7, 5);
    EXPECT_EQ(5, tDInt->access(7, 5));
    delete tDInt;
}
예제 #14
0
TEST(Sparse, Access) {
	SparseArray<std::string>* newSparse = new SparseArray<std::string>(20,20,"null");
	EXPECT_EQ("null", newSparse->access(10,10));
	newSparse->insert(15,17,"howdy");
	EXPECT_EQ("howdy", newSparse->access(15,17));
	delete newSparse;

	SparseArray<int>* newInt = new SparseArray<int>(20,20,7);
	EXPECT_EQ(7, newInt->access(10,10));
	newInt->insert(15,17,14);
	EXPECT_EQ(14, newInt->access(15,17));
	delete newInt;
	
	SparseArray<double>* newDouble = new SparseArray<double>(20,20,5.5);
	EXPECT_EQ(5.5, newDouble->access(10,10));
	newDouble->insert(15,17,6.6);
	EXPECT_EQ(6.6, newDouble->access(15,17));
	delete newDouble;
}