BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / test / dictionary / Test-dictionary.C
blob42bdcabeaf813ac0908c0dab0c1e46a5c1f659f6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Application
25     dictionaryTest
27 Description
29 \*---------------------------------------------------------------------------*/
31 #include "argList.H"
32 #include "IOstreams.H"
33 #include "IOobject.H"
34 #include "IFstream.H"
35 #include "dictionary.H"
37 using namespace Foam;
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 //  Main program:
42 int main(int argc, char *argv[])
44     argList::noParallel();
45     argList::validArgs.insert("dict .. dictN");
46     argList args(argc, argv, false, true);
48     Info<< nl
49         << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
50         << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
51         << endl;
53     if (args.size() <= 1)
54     {
55         {
56             dictionary dict1(IFstream("testDict")());
57             Info<< "dict1: " << dict1 << nl
58                 << "toc: " << dict1.toc() << nl
59                 << "keys: " << dict1.keys() << nl
60                 << "patterns: " << dict1.keys(true) << endl;
62             dictionary dict2(dict1.xfer());
64             Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl
65                 << "dict2.toc(): " << dict2.name() << " " << dict2.toc()
66                 << endl;
68             // copy back
69             dict1 = dict2;
70             Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc()
71                 << endl;
73             dictionary dict3(dict2.subDictPtr("boundaryField"));
74             dictionary dict4(dict2.subDictPtr("NONEXISTENT"));
76             Info<< "dictionary construct from pointer" << nl
77                 << "ok = " << dict3.name() << " " << dict3.toc() << nl
78                 << "no = " << dict4.name() << " " << dict4.toc() << endl;
79         }
82         IOobject::writeDivider(Info);
84         {
85             dictionary dict(IFstream("testDictRegex")());
86             dict.add(keyType("fooba[rz]", true), "anything");
88             Info<< "dict:" << dict << nl
89                 << "toc: " << dict.toc() << nl
90                 << "keys: " << dict.keys() << nl
91                 << "patterns: " << dict.keys(true) << endl;
93             Info<< "Pattern find \"abc\" in top directory : "
94                 << dict.lookup("abc") << endl;
95             Info<< "Pattern find \"abc\" in sub directory : "
96                 << dict.subDict("someDict").lookup("abc")
97                     << endl;
98             Info<< "Recursive pattern find \"def\" in sub directory : "
99                 << dict.subDict("someDict").lookup("def", true)
100                     << endl;
101             Info<< "Recursive pattern find \"foo\" in sub directory : "
102                 << dict.subDict("someDict").lookup("foo", true)
103                     << endl;
104             Info<< "Recursive pattern find \"fooz\" in sub directory : "
105                 << dict.subDict("someDict").lookup("fooz", true)
106                     << endl;
107             Info<< "Recursive pattern find \"bar\" in sub directory : "
108                 << dict.subDict("someDict").lookup("bar", true)
109                     << endl;
110             Info<< "Recursive pattern find \"xxx\" in sub directory : "
111                 << dict.subDict("someDict").lookup("xxx", true)
112                     << endl;
113         }
114     }
115     else
116     {
117         IOobject::writeDivider(Info);
118         for (label argI=1; argI < args.size(); ++argI)
119         {
120             const string& dictFile = args[argI];
121             IFstream is(dictFile);
123             dictionary dict(is);
125             Info<< dict << endl;
126         }
127     }
129     return 0;
133 // ************************************************************************* //