Skip to content
Snippets Groups Projects
Commit eabe512e authored by Jorrit Fahlke's avatar Jorrit Fahlke
Browse files

[ConfigParser] Test extraction of FieldVector and std::vector.

[[Imported from SVN: r6030]]
parent 9d6b2672
No related branches found
No related tags found
No related merge requests found
......@@ -6,9 +6,11 @@
#include <iostream>
#include <string>
#include <vector>
#include <dune/common/configparser.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/fvector.hh>
int main ()
{
......@@ -18,10 +20,23 @@ int main ()
parameterSet["testDouble"] = "3.14";
parameterSet["testInt"] = "42";
parameterSet["testString"] = "Hallo Welt!";
parameterSet["testVector"] = "2 3 5 7 11";
double testDouble = parameterSet.get<double>("testDouble");
int testInt = parameterSet.get<int>("testInt");
std::string testString = parameterSet.get<std::string>("testString");
typedef Dune::FieldVector<unsigned, 5> FVector;
FVector testFVector = parameterSet.get<FVector>("testVector");
typedef std::vector<unsigned> SVector;
SVector testSVector = parameterSet.get<SVector>("testVector");
if(testSVector.size() != 5)
DUNE_THROW(Dune::Exception, "Testing std::vector<unsigned>: expected "
"size()==5, got size()==" << testSVector.size());
for(unsigned i = 0; i < 5; ++i)
if(testFVector[i] != testSVector[i])
DUNE_THROW(Dune::Exception,
"testFVector[" << i << "]==" << testFVector[i] << " but "
"testSVector[" << i << "]==" << testSVector[i]);
}
catch(const Dune::Exception& e) {
std::cerr << "Exception thrown: " << e << std::endl;
......
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