diff --git a/applications/test/HashTable1/Test-HashTable1.C b/applications/test/HashTable1/Test-HashTable1.C index 6f92ffcd8f..75e4eeda2d 100644 --- a/applications/test/HashTable1/Test-HashTable1.C +++ b/applications/test/HashTable1/Test-HashTable1.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,7 +33,7 @@ License #include "IOstreams.H" #include "StringStream.H" #include "ListOps.H" -#include "StringListOps.H" +#include "stringListOps.H" using namespace Foam; @@ -71,9 +71,18 @@ int main() << "table1 [" << table1.size() << "] " << endl; forAllConstIters(table1, iter) { - Info<< iter.key() << " => " << iter() << nl; + Info<< iter.key() << " => " << iter.val() << nl; } + + Info<< "\ntable1 sorted() :" << endl; + for (const auto& iter : table1.sorted()) + { + Info<< " " << iter.key() << " => " << iter.val() << nl; + } + Info<< endl; + + table1.set("acr", 108); table1.set("adx", 109); table1.set("aec", 100); @@ -82,6 +91,22 @@ int main() Info<< "\noverwrote some values table1: " << table1 << endl; + + // Test writable sorted access + for (auto& iter : table1.sorted()) + { + // Should not compile: iter.key() = "illegal"; + iter.val() *= 2; + } + + Info<< "\nInplace modified - via sorted() access :" << endl; + for (const auto& iter : table1.sorted()) + { + Info<< " " << iter.key() << " => " << iter.val() << nl; + } + Info<< endl; + + Info<< "\ntest find:" << endl; Info<< table1.find("aaa")() << nl << table1.find("aba")() << nl diff --git a/applications/test/IOField/Test-IOField.C b/applications/test/IOField/Test-IOField.C index 97a4774b61..729a7c85e5 100644 --- a/applications/test/IOField/Test-IOField.C +++ b/applications/test/IOField/Test-IOField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,6 +34,7 @@ Description #include "argList.H" #include "IOField.H" +#include "IOList.H" #include "primitiveFields.H" #include "polyMesh.H" #include "Time.H" @@ -181,6 +182,7 @@ int main(int argc, char *argv[]) argList::addBoolOption("bool", "Use bool for tests"); argList::addBoolOption("scalar", "Use scalar for tests"); argList::addBoolOption("label", "Use label for tests (default)"); + argList::addBoolOption("ref", "Test writing by ref"); #include "addTimeOptions.H" @@ -232,6 +234,36 @@ int main(int argc, char *argv[]) doTests