mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
small changes to dictionaryTest to test regexs
This commit is contained in:
@ -30,6 +30,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOstreams.H"
|
||||
#include "IOobject.H"
|
||||
#include "IFstream.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
@ -40,18 +41,12 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
IFstream dictStream("testDict");
|
||||
dictionary testDict(dictStream);
|
||||
Info<< dictionary(IFstream("testDict")()) << endl;
|
||||
|
||||
Info<< testDict << endl;
|
||||
IOobject::writeDivider(Info);
|
||||
|
||||
{
|
||||
dictionary someDict;
|
||||
someDict.add(keyType("a.*", true), "subdictValue");
|
||||
|
||||
dictionary dict;
|
||||
dict.add("someDict", someDict);
|
||||
dict.add(keyType(".*", true), "parentValue");
|
||||
dictionary dict(IFstream("testDictRegex")());
|
||||
|
||||
Info<< "dict:" << dict << endl;
|
||||
|
||||
@ -64,6 +59,18 @@ int main(int argc, char *argv[])
|
||||
Info<< "Recursive wildcard find \"def\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("def", true)
|
||||
<< endl;
|
||||
Info<< "Recursive wildcard find \"foo\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("foo", true)
|
||||
<< endl;
|
||||
Info<< "Recursive wildcard find \"fooz\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("fooz", true)
|
||||
<< endl;
|
||||
Info<< "Recursive wildcard find \"bar\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("bar", true)
|
||||
<< endl;
|
||||
Info<< "Recursive wildcard find \"xxx\" in sub directory : "
|
||||
<< dict.subDict("someDict").lookup("xxx", true)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
34
applications/test/dictionary/testDictRegex
Normal file
34
applications/test/dictionary/testDictRegex
Normal file
@ -0,0 +1,34 @@
|
||||
/*-------------------------------*- C++ -*---------------------------------*\
|
||||
| ========= |
|
||||
| \\ / OpenFOAM |
|
||||
| \\ / |
|
||||
| \\ / The Open Source CFD Toolbox |
|
||||
| \\/ http://www.OpenFOAM.org |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object testDictRegex;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#inputMode merge
|
||||
|
||||
".*" parentValue1;
|
||||
"[n-z].*" parentValue2;
|
||||
"f.*" parentValue3;
|
||||
|
||||
someDict
|
||||
{
|
||||
foo subdictValue0;
|
||||
bar $f.*; // should this really match 'foo'?
|
||||
|
||||
// result is dependent on insert order!
|
||||
"a.*c" subdictValue3;
|
||||
"ab.*" subdictValue2;
|
||||
"a.*" subdictValue1;
|
||||
abcd subdictValue4;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
Reference in New Issue
Block a user