Skip to content
Snippets Groups Projects
Commit 09d70bfe authored by Christoph Grüninger's avatar Christoph Grüninger Committed by Christoph Grüninger
Browse files

Fix Wshadow warnings in test code

parent b9deda92
No related branches found
No related tags found
1 merge request!21Feature/fix shadow warnings
......@@ -300,11 +300,11 @@ void test_matrix()
DUNE_THROW(FMatrixError,"Axpy test failed!");
}
{
DynamicMatrix<K> A(n,n+1);
for(size_type i=0; i<A.N(); ++i)
for(size_type j=0; j<A.M(); ++j)
A[i][j] = i;
const DynamicMatrix<K>& Aref DUNE_UNUSED = A;
DynamicMatrix<K> A2(n,n+1);
for(size_type i=0; i<A2.N(); ++i)
for(size_type j=0; j<A2.M(); ++j)
A2[i][j] = i;
const DynamicMatrix<K>& Aref DUNE_UNUSED = A2;
DynamicMatrix<K> B(n+1,n+1);
......
......@@ -299,11 +299,11 @@ void test_matrix()
DUNE_THROW(FMatrixError,"Axpy test failed!");
}
{
FieldMatrix<K,n,n+1> A;
for(size_type i=0; i<A.N(); ++i)
for(size_type j=0; j<A.M(); ++j)
A[i][j] = i;
const FieldMatrix<K,n,n+1>& Aref = A;
FieldMatrix<K,n,n+1> A2;
for(size_type i=0; i<A2.N(); ++i)
for(size_type j=0; j<A2.M(); ++j)
A2[i][j] = i;
const FieldMatrix<K,n,n+1>& Aref = A2;
FieldMatrix<K,n+1,n+1> B;
......@@ -324,13 +324,13 @@ void test_matrix()
if (std::abs(AB[i][j] - K(i*n*(n+1)/2)) > 1e-10)
DUNE_THROW(FMatrixError,"Rightmultiplyany test failed!");
FieldMatrix<K,n,n+1> AB2 = A;
FieldMatrix<K,n,n+1> AB2 = A2;
AB2.rightmultiply(B);
AB2 -= AB;
if (std::abs(AB2.infinity_norm()) > 1e-10)
DUNE_THROW(FMatrixError,"Rightmultiply test failed!");
FieldMatrix<K,n,n+1> AB3 = Bref.leftmultiplyany(A);
FieldMatrix<K,n,n+1> AB3 = Bref.leftmultiplyany(A2);
AB3 -= AB;
if (std::abs(AB3.infinity_norm()) > 1e-10)
DUNE_THROW(FMatrixError,"Leftmultiplyany test failed!");
......@@ -341,13 +341,13 @@ void test_matrix()
if (std::abs(CA[i][j] - K(i*n*(n-1)/2)) > 1e-10)
DUNE_THROW(FMatrixError,"Leftmultiplyany test failed!");
FieldMatrix<K,n,n+1> CA2 = A;
FieldMatrix<K,n,n+1> CA2 = A2;
CA2.leftmultiply(C);
CA2 -= CA;
if (std::abs(CA2.infinity_norm()) > 1e-10)
DUNE_THROW(FMatrixError,"Leftmultiply test failed!");
FieldMatrix<K,n,n+1> CA3 = Cref.rightmultiplyany(A);
FieldMatrix<K,n,n+1> CA3 = Cref.rightmultiplyany(A2);
CA3 -= CA;
if (std::abs(CA3.infinity_norm()) > 1e-10)
DUNE_THROW(FMatrixError,"Rightmultiplyany test failed!");
......
......@@ -177,7 +177,8 @@ int testRandomAccessIterator(Iter begin, Iter end, Opt opt){
<<"iterator and n is the difference type!" <<std::endl;
ret++;
}
for(int i=0; i< index; i++) ++test;
for(int j = 0; j < index; j++)
++test;
if(test != rand)
{
......@@ -196,7 +197,8 @@ int testRandomAccessIterator(Iter begin, Iter end, Opt opt){
<<"iterator and n is the difference type!" <<std::endl;
ret++;
}
for(int i=0; i< index; i++) --test;
for(int j = 0; j < index; j++)
--test;
if(test != rand)
{
......
......@@ -96,11 +96,11 @@ int main(){
// test custom deleter
bool deleted = false;
{
shared_ptr<int> foo(new int(1), Deleter<int>(deleted));
shared_ptr<int> bar(new int(1), Deleter<int>(deleted));
//test if deleter is called
deleted = false;
foo.reset(new int(2)); // this should call the deleter in the constructor
bar.reset(new int(2)); // this should call the deleter in the constructor
if (not (deleted))
{
std::cout << "Custom deleter not called!" << std::endl;
......@@ -109,7 +109,7 @@ int main(){
//test if old deleter is not called
deleted = false;
foo.reset(); // this should call no deleter
bar.reset(); // this should call no deleter
if (deleted)
{
std::cout << "Old deleter was called!" << std::endl;
......@@ -118,7 +118,7 @@ int main(){
//test if old deleter is not called
deleted = false;
foo.reset(new int(3), Deleter<int>(deleted)); // this should call no deleter
bar.reset(new int(3), Deleter<int>(deleted)); // this should call no deleter
if (deleted)
{
std::cout << "Old deleter was called!" << std::endl;
......@@ -132,9 +132,9 @@ int main(){
ret=1;
}
{
shared_ptr<int> foo(new int(1), Deleter<int>(deleted));
shared_ptr<int> bar(new int(1), Deleter<int>(deleted));
foo.reset(new int(4)); // this should call the deleter...
bar.reset(new int(4)); // this should call the deleter...
deleted = false;
// ... but going out of scope should call no deleter
......@@ -219,10 +219,10 @@ int main(){
// test assignment from null ptr
// (should trigger FS 936, needs valgrind to check)
{
shared_ptr<int> foo = shared_ptr<int>(new int(42));
shared_ptr<int> bar; //null ptr
shared_ptr<int> foobar = shared_ptr<int>(new int(42));
shared_ptr<int> foobaz; //null ptr
foo = bar; // should release memory held by foo
foobar = foobaz; // should release memory held by foo
}
// test shared_ptr for stack allocation
......@@ -233,8 +233,8 @@ int main(){
// test shared_ptr for stack allocation with down cast
{
B b;
shared_ptr<A> pa = stackobject_to_shared_ptr<A>(b);
B b2;
shared_ptr<A> pa = stackobject_to_shared_ptr<A>(b2);
#ifdef SHARED_PTR_COMPILE_FAIL
C c;
pa = stackobject_to_shared_ptr<A>(c); // A is an inaccessible base of C
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment