コード例 #1
0
TEUCHOS_UNIT_TEST(Teuchos_TwoDArray, resizeTest){
  TwoDArray<int> simpleArray = getSimpleTestTwoDArray();

  simpleArray.resizeRows(4);
  TEST_EQUALITY_CONST(simpleArray.getNumRows(), 4);
  TEST_EQUALITY_CONST(simpleArray.getNumCols(), 2);
  TEST_EQUALITY_CONST(simpleArray(3,1), 0);
  TEST_EQUALITY_CONST(simpleArray(1,1), 4);

  simpleArray.resizeRows(2);
  TEST_EQUALITY_CONST(simpleArray.getNumRows(), 2);
  TEST_EQUALITY_CONST(simpleArray.getNumCols(), 2);
#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
  TEST_THROW(simpleArray(3,1), RangeError);
#endif
  TEST_EQUALITY_CONST(simpleArray(1,1), 4);

  simpleArray.resizeCols(4);
  TEST_EQUALITY_CONST(simpleArray.getNumCols(), 4);
  TEST_EQUALITY_CONST(simpleArray.getNumRows(), 2);
  TEST_EQUALITY_CONST(simpleArray(1,3), 0);
  TEST_EQUALITY_CONST(simpleArray(1,1), 4);

  simpleArray.resizeCols(2);
  TEST_EQUALITY_CONST(simpleArray.getNumCols(), 2);
  TEST_EQUALITY_CONST(simpleArray.getNumRows(), 2);
#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
  TEST_THROW(simpleArray(1,3), RangeError);
#endif
  TEST_EQUALITY_CONST(simpleArray(1,1), 4);

}
コード例 #2
0
TEST(TwoDArrayCol, NumCol) {
    TwoDArray<int>* tDInt = new TwoDArray<int>(10, 10, 0);
    TwoDArray<double>* tDDouble = new TwoDArray<double>(11, 11, 0.0);
    TwoDArray<string>* tDString = new TwoDArray<string>(12, 12, "0");

    EXPECT_EQ(10, tDInt->getNumCols());
    delete tDInt;
    EXPECT_EQ(11, tDDouble->getNumCols());
    delete tDDouble;
    EXPECT_EQ(12, tDString->getNumCols());
    delete tDString;
}
コード例 #3
0
TEST(TwoDArray, GetNumCols) {
	TwoDArray<int>* newArray = new TwoDArray<int>(7,8,0);
	EXPECT_EQ(7, newArray->getNumCols());
	delete newArray;
	
	TwoDArray<double>* newDouble = new TwoDArray<double>(562,786,1.2);
	EXPECT_EQ(562, newDouble->getNumCols());
	delete newDouble;

	TwoDArray<std::string>* newString = new TwoDArray<std::string>(5,6, "bye");
	EXPECT_EQ(5, newString->getNumCols());
	delete newString;
}
コード例 #4
0
ファイル: TwoDArray.cpp プロジェクト: aviindub/TwoDArray
TEST(numCols, stringTest) {
    int r = 5;
    int c = 10;
    TwoDArray<string>* a = new TwoDArray<string>(r, c);
    EXPECT_EQ(10, a->getNumCols());
    delete a;
}
コード例 #5
0
ファイル: TwoDArray.cpp プロジェクト: aviindub/TwoDArray
TEST(numCols, doubleTest) {
    int r = 5;
    int c = 10;
    TwoDArray<double>* a = new TwoDArray<double>(r, c);
    EXPECT_EQ(10, a->getNumCols());
    delete a;
}
コード例 #6
0
ファイル: TwoDArray.cpp プロジェクト: aviindub/TwoDArray
TEST(numCols, integerTest) {
    int r = 5;
    int c = 10;
    TwoDArray<int>* a = new TwoDArray<int>(r, c);
    EXPECT_EQ(10, a->getNumCols());
    delete a;
}
コード例 #7
0
TEUCHOS_UNIT_TEST(Teuchos_TwoDArrays, emptyTest){
  TwoDArray<int> emptyArray;
  TEST_EQUALITY_CONST(emptyArray.getNumRows(), 0)
  TEST_EQUALITY_CONST(emptyArray.getNumCols(), 0)
  TEST_EQUALITY_CONST(emptyArray.getDataArray().size(), 0)
  TEST_ASSERT(emptyArray.isEmpty());
}
コード例 #8
0
TEST(arrayTest, getNumCols) {
  TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
  TwoDArray<double>* d = new TwoDArray<int>(5, 10, 0);
  TwoDArray<std::string>* s = new TwoDArray<std::string>(5, 19, 0);

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

  EXPECT_EQ(5, i->getNumCols());
  EXPECT_EQ(10, d->getNumCols());
  EXPECT_EQ(19, s->getNumCols());

  delete i;
  delete d;
  delete s;
}
コード例 #9
0
ファイル: TwoDArray.cpp プロジェクト: aviindub/TwoDArray
TEST(constructor, stringTest) {
    int r = 10;
    int c = 10;
    TwoDArray<string>* a = new TwoDArray<string>(r, c);
    EXPECT_EQ(r, a->getNumRows());
    EXPECT_EQ(c, a->getNumCols());
    delete a;
}
コード例 #10
0
ファイル: TwoDArray.cpp プロジェクト: aviindub/TwoDArray
TEST(constructor, doubleTest) {
    int r = 10;
    int c = 10;
    TwoDArray<double>* a = new TwoDArray<double>(r, c);
    EXPECT_EQ(r, a->getNumRows());
    EXPECT_EQ(c, a->getNumCols());
    delete a;
}
コード例 #11
0
ファイル: TwoDArray.cpp プロジェクト: aviindub/TwoDArray
TEST(constructor, integerTest) {
    int r = 10;
    int c = 10;
    TwoDArray<int>* a = new TwoDArray<int>(r, c);
    EXPECT_EQ(r, a->getNumRows());
    EXPECT_EQ(c, a->getNumCols());
    delete a;
}
コード例 #12
0
/**
 * Test the TwoDColDependency.
 */
TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testTwoDColDependency){
	RCP<ParameterList> My_deplist = RCP<ParameterList>(new ParameterList);
	RCP<DependencySheet> depSheet1 =
    RCP<DependencySheet>(new DependencySheet);

	ParameterList
	colNumDepList = My_deplist->sublist(
    "2D Col Depdency List", false,
    "2D Col Dependecy testing list.");
	colNumDepList.set("Num cols", 2, "num cols setter");
  TwoDArray<double> variableColsArray(11,3,16.5);
	RCP<EnhancedNumberValidator<double> >
	varColArrayVali = RCP<EnhancedNumberValidator<double> >(
  		new EnhancedNumberValidator<double>(10,50,4)
	);
	colNumDepList.set(
    "Variable Col Array", variableColsArray, "variable col array",
	  RCP<TwoDArrayNumberValidator<double> >(
      new TwoDArrayNumberValidator<double>(varColArrayVali)));

	RCP<TwoDColDependency<int, double> >
	  arrayColDep = rcp(
  		new TwoDColDependency<int, double>(
		  colNumDepList.getEntryRCP("Num cols"),
			colNumDepList.getEntryRCP("Variable Col Array") ,
      rcp(new AdditionFunction<int>(1))
		)
	);
	depSheet1->addDependency(arrayColDep);
  TwoDArray<double> curArray =
    colNumDepList.get<TwoDArray<double> >("Variable Col Array");
	TEST_EQUALITY_CONST(curArray.getNumCols(),3);
	colNumDepList.set("Num cols", 4);
	arrayColDep()->evaluate();
  curArray =
    colNumDepList.get<TwoDArray<double> >("Variable Col Array");
	TEST_EQUALITY_CONST(curArray.getNumCols(),5);
	colNumDepList.set("Num cols", -2);
	TEST_THROW(arrayColDep()->evaluate(),
    Exceptions::InvalidParameterValue);
}
コード例 #13
0
std::string TwoDArray<T>::toString(const TwoDArray<T> array){
  std::stringstream numColsStream;
  std::stringstream numRowsStream;
  numColsStream << array.getNumCols();
  numRowsStream << array.getNumRows();
  std::string metaSeperator = TwoDArray<T>::getMetaSeperator();
  return
    numRowsStream.str() +
    TwoDArray<T>::getDimensionsDelimiter() +
    numColsStream.str() +
    metaSeperator +
    (array.isSymmetrical() ? "sym"+metaSeperator : "") +
    array.getDataArray().toString();
}
コード例 #14
0
ファイル: test.cpp プロジェクト: Derbs/CSCI333-Project2
int main() {
  TwoDArray<int>* victim = new TwoDArray<int>(5,10,0);
  for(int i = 0; i<victim->getNumRows(); i++) {
    for(int j = 0; j<victim->getNumCols(); j++) {
      victim->insert(i,j,i+j);
    }
  }
  victim->print();
  delete victim;
  TwoDArray<std::string>* victim2 = new TwoDArray<std::string>(3,2,"moo");
  victim2->print();
  delete victim2;
  return 0;
}