From 8884d58a5235d2666b86f836f31a20bca03d51c1 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 29 Jun 2021 12:28:11 +0200 Subject: [PATCH] STYLE: fix/correct some tests. Remove useless tests --- .../test/HashTable1/Test-HashTable1.C | 17 +++-- applications/test/ITstream/Test-ITstream.C | 14 +++- applications/test/alloc/Make/files | 8 --- applications/test/alloc/Make/options | 2 - applications/test/alloc/Test-alloc.C | 27 -------- applications/test/alloc/Test-malloc.C | 30 --------- applications/test/alloc/Test-new.C | 30 --------- applications/test/alloc/Test.C | 64 ------------------- applications/test/bitSet2/Test-bitSet2.C | 2 +- applications/test/cyclic/Test-cyclic.C | 2 + applications/test/field1/Test-field1.C | 13 ++-- applications/test/fvc/Test-fvc.C | 2 + applications/test/fvc2D/Test-fvc2D.C | 2 + applications/test/graph/Test-graph.C | 2 + applications/test/graph/graphTest2.C | 2 + .../test/hashedWordList/Test-hashedWordList.C | 3 +- applications/test/io/Test-io.C | 3 + .../test/predicates/Test-predicates.C | 5 +- applications/test/readDir/Test-readDir.C | 4 +- .../Make/options | 2 + .../Test-reconstructedDistanceFunction.C | 4 +- applications/test/refPtr/Test-refPtr.C | 2 + applications/test/scalarOps/Test-scalarOps.C | 2 +- .../test/speed/scalarSpeed/Test-scalarSpeed.C | 2 + .../test/speed/vectorSpeed/Test-vectorSpeed.C | 2 + applications/test/tmp/Test-tmp.C | 2 + applications/test/wordRe/Test-wordRe.C | 2 +- 27 files changed, 62 insertions(+), 188 deletions(-) delete mode 100644 applications/test/alloc/Make/files delete mode 100644 applications/test/alloc/Make/options delete mode 100644 applications/test/alloc/Test-alloc.C delete mode 100644 applications/test/alloc/Test-malloc.C delete mode 100644 applications/test/alloc/Test-new.C delete mode 100644 applications/test/alloc/Test.C diff --git a/applications/test/HashTable1/Test-HashTable1.C b/applications/test/HashTable1/Test-HashTable1.C index a7daa437502..3fa46376d43 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 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,11 +28,12 @@ License #include "HashTable.H" #include "List.H" -#include "SortableList.H" #include "DynamicList.H" #include "FlatOutput.H" #include "IOstreams.H" #include "StringStream.H" +#include "ListOps.H" +#include "flipOp.H" using namespace Foam; @@ -209,12 +210,16 @@ int main() << "/" << table1.keys().size() << nl; - SortableList<word> sortKeys - // DynamicList<word> sortKeys + List<word> sortKeys ( - table1.keys().begin(), - table1.keys().end() + ListOps::create<word> + ( + table1.keys().begin(), + table1.keys().end(), + noOp{} + ) ); + sort(sortKeys); Info<<"sortKeys: " << flatOutput(sortKeys) << nl; } diff --git a/applications/test/ITstream/Test-ITstream.C b/applications/test/ITstream/Test-ITstream.C index aad746cd9ae..2066cfbf96c 100644 --- a/applications/test/ITstream/Test-ITstream.C +++ b/applications/test/ITstream/Test-ITstream.C @@ -33,6 +33,8 @@ Description #include "IOstreams.H" #include "argList.H" #include "ITstream.H" +#include "ListOps.H" +#include "flipOp.H" using namespace Foam; @@ -109,7 +111,7 @@ void doTest << nl << "====" << nl << endl; - ITstream its(name, input); + ITstream its(input); Info<< "got " << its.size() << " tokens - index at " << its.tokenIndex() << endl; @@ -164,7 +166,15 @@ int main(int argc, char *argv[]) string stringInput("( string ; input \"string\" to tokenize )"); - List<char> listInput(stringInput.cbegin(), stringInput.cend()); + List<char> listInput + ( + ListOps::create<char> + ( + stringInput.cbegin(), + stringInput.cend(), + Foam::noOp{} + ) + ); doTest("empty", "", true, true); diff --git a/applications/test/alloc/Make/files b/applications/test/alloc/Make/files deleted file mode 100644 index 5b51a06854e..00000000000 --- a/applications/test/alloc/Make/files +++ /dev/null @@ -1,8 +0,0 @@ -Test-alloc.C -/* -Test-new.C -Test-malloc.C -Test.C -*/ - -EXE = $(FOAM_USER_APPBIN)/Test-alloc diff --git a/applications/test/alloc/Make/options b/applications/test/alloc/Make/options deleted file mode 100644 index 4e772fdf9d7..00000000000 --- a/applications/test/alloc/Make/options +++ /dev/null @@ -1,2 +0,0 @@ -/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ -/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/alloc/Test-alloc.C b/applications/test/alloc/Test-alloc.C deleted file mode 100644 index db4318475b5..00000000000 --- a/applications/test/alloc/Test-alloc.C +++ /dev/null @@ -1,27 +0,0 @@ -#include <iostream> -#include <unistd.h> - -using namespace std; - -int main() -{ - int *ptrs[500000]; - -// for (;;); - - cerr << "allocating ints\n"; - - for (int i=0; i<500000; i++) - { - ptrs[i] = new int[1]; - delete[] ptrs[i]; - } - - for (;;); - - cerr << "allocating double\n"; - - double* array = new double[500000]; - - for (;;); -} diff --git a/applications/test/alloc/Test-malloc.C b/applications/test/alloc/Test-malloc.C deleted file mode 100644 index 4bfc18a20ed..00000000000 --- a/applications/test/alloc/Test-malloc.C +++ /dev/null @@ -1,30 +0,0 @@ -#include "stream.h" -#include <unistd.h> -#include <cstdlib> - -main() -{ - int *ptrs[500000]; - - cerr << "allocating ints\n"; - - for (int i=0; i<500000; i++) - { - ptrs[i] = (int*)malloc(sizeof(int)); - } - -// for (;;); - - cerr << "deallocating ints\n"; - - for (i=0; i<500000; i++) - { - free(ptrs[i]); - } - - cerr << "allocating double\n"; - - double* array = (double*)malloc(500000*sizeof(double)); - - for (;;); -} diff --git a/applications/test/alloc/Test-new.C b/applications/test/alloc/Test-new.C deleted file mode 100644 index 7609172b006..00000000000 --- a/applications/test/alloc/Test-new.C +++ /dev/null @@ -1,30 +0,0 @@ -#include <stream.h> - -main() -{ - int* intPtrs[500000]; - - cerr << "allocating ints\n"; - - for (int i=0; i<500000; i++) - { - intPtrs[i] = new int[1]; - } - - cerr << "allocated ints\n"; - - cerr << "deallocating ints\n"; - - for (i=0; i<500000; i++) - { - delete[] intPtrs[i]; - } - - cerr << "deallocated ints\n"; - - cerr << "alloacting doubles\n"; - - double* doubles = new double[500000]; - - for (;;); -} diff --git a/applications/test/alloc/Test.C b/applications/test/alloc/Test.C deleted file mode 100644 index a2de8b24df8..00000000000 --- a/applications/test/alloc/Test.C +++ /dev/null @@ -1,64 +0,0 @@ -#include <cstdlib> - -class Int -{ - int I; - -public: - - Int(){} - - operator int() - { - return I; - } -}; - - -template<class T> -class List : public T -{ - T* v; - int sz; - -public: - - List() - { - v = new T[sz=10]; - } - - List(int s) - { - v = new T[sz=s]; - } - - ~List() - { - delete[] v; - } - - inline int size() const; - -}; - - -template<class T> -inline int List<T>::size() const -{ - return sz; -} - - -#include <stream.h> - -main() -{ - typedef List<Int> intList; - - intList list(10); - - cout << list.size() << "\n"; - - return 0; -} diff --git a/applications/test/bitSet2/Test-bitSet2.C b/applications/test/bitSet2/Test-bitSet2.C index df3bd8f938e..df04f3ce0f9 100644 --- a/applications/test/bitSet2/Test-bitSet2.C +++ b/applications/test/bitSet2/Test-bitSet2.C @@ -390,7 +390,7 @@ int main(int argc, char *argv[]) // Info<< list5 << " indices: " << list5.toc() << nl; Info<< "\nassign from indices\n"; - list4.read + list4.readList ( IStringStream ( diff --git a/applications/test/cyclic/Test-cyclic.C b/applications/test/cyclic/Test-cyclic.C index 3c7daa70836..8952f34e117 100644 --- a/applications/test/cyclic/Test-cyclic.C +++ b/applications/test/cyclic/Test-cyclic.C @@ -58,6 +58,8 @@ int main(int argc, char *argv[]) Info<< fvc::div(U); Info<< "End\n" << endl; + + return 0; } diff --git a/applications/test/field1/Test-field1.C b/applications/test/field1/Test-field1.C index 2cd6bc6c01d..8808c5d4255 100644 --- a/applications/test/field1/Test-field1.C +++ b/applications/test/field1/Test-field1.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -187,9 +187,7 @@ int main(int argc, char *argv[]) Sout.precision(16); const scalar SMALLS(1e-6); - const vector SMALLV(SMALLS, SMALLS, SMALLS); const scalar GREATS(1e6); - const vector GREATV(GREATS, GREATS, GREATS); // scalarField summation { @@ -203,9 +201,9 @@ int main(int argc, char *argv[]) } // vectorField summation { - vectorField vfield(10, SMALLV); + vectorField vfield(10, vector::uniform(SMALLS)); - vfield[8] = GREATV; + vfield[8] = vector::uniform(GREATS); vfield[9] = -vfield[8]; Info<< "vectorField:" << vfield.size() << nl << " sum :" << sum(vfield) << nl @@ -213,9 +211,9 @@ int main(int argc, char *argv[]) } // sphericalTensorField summation { - sphericalTensorField tfield(10, SMALLS); + sphericalTensorField tfield(10, sphericalTensor(SMALLS)); - tfield[8] = GREATS; + tfield[8] = sphericalTensor(GREATS); tfield[9] = -tfield[8]; Info<< "sphericalTensorField:" << tfield.size() << nl << " sum :" << sum(tfield) << nl @@ -243,7 +241,6 @@ int main(int argc, char *argv[]) } - return 0; } diff --git a/applications/test/fvc/Test-fvc.C b/applications/test/fvc/Test-fvc.C index 14cac2e2775..3b51e2204cb 100644 --- a/applications/test/fvc/Test-fvc.C +++ b/applications/test/fvc/Test-fvc.C @@ -60,6 +60,8 @@ int main(int argc, char *argv[]) } Info<< "End\n" << endl; + + return 0; } diff --git a/applications/test/fvc2D/Test-fvc2D.C b/applications/test/fvc2D/Test-fvc2D.C index f4f00c71338..fb9053bddac 100644 --- a/applications/test/fvc2D/Test-fvc2D.C +++ b/applications/test/fvc2D/Test-fvc2D.C @@ -68,6 +68,8 @@ int main(int argc, char *argv[]) ); Info<< "End\n" << endl; + + return 0; } diff --git a/applications/test/graph/Test-graph.C b/applications/test/graph/Test-graph.C index 30739da80c6..1b3811abddf 100644 --- a/applications/test/graph/Test-graph.C +++ b/applications/test/graph/Test-graph.C @@ -68,6 +68,8 @@ int main() phi.write("phi", "xmgr"); Info<< "End\n" << endl; + + return 0; } diff --git a/applications/test/graph/graphTest2.C b/applications/test/graph/graphTest2.C index 2e80e019b51..5564af67195 100644 --- a/applications/test/graph/graphTest2.C +++ b/applications/test/graph/graphTest2.C @@ -60,6 +60,8 @@ int main() ); Info<< "End\n" << endl; + + return 0; } diff --git a/applications/test/hashedWordList/Test-hashedWordList.C b/applications/test/hashedWordList/Test-hashedWordList.C index d23de96f780..db2617eb2e1 100644 --- a/applications/test/hashedWordList/Test-hashedWordList.C +++ b/applications/test/hashedWordList/Test-hashedWordList.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -157,7 +157,6 @@ int main(int argc, char *argv[]) { ITstream input ( - "input", "(plain list with some with list duplicates)" ); diff --git a/applications/test/io/Test-io.C b/applications/test/io/Test-io.C index 2dbfcca89ec..8aabf294097 100644 --- a/applications/test/io/Test-io.C +++ b/applications/test/io/Test-io.C @@ -74,6 +74,9 @@ int main(void) Info.operator Foam::OSstream&() << "stop" << endl; static_cast<OSstream&>(Info) << "\nEnd\n" << nl; + + return 0; } + // ************************************************************************* // diff --git a/applications/test/predicates/Test-predicates.C b/applications/test/predicates/Test-predicates.C index 2fb27cac95e..246e6fccebd 100644 --- a/applications/test/predicates/Test-predicates.C +++ b/applications/test/predicates/Test-predicates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,8 +79,7 @@ int main(int argc, char *argv[]) "hij_", }; - labelRange range(-10, 40); - labelList values(range.begin(), range.end()); + labelList values(identity(40, -10)); Info<<"words: " << flatOutput(words) << endl; Info<<"values: " << flatOutput(values) << endl; diff --git a/applications/test/readDir/Test-readDir.C b/applications/test/readDir/Test-readDir.C index 451828bd2dc..69af65411d8 100644 --- a/applications/test/readDir/Test-readDir.C +++ b/applications/test/readDir/Test-readDir.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) { Info<< nl; - for (const word& item : readDir(".", listType)) + for (const auto& item : readDir(".", listType)) { Info<< " " << item << nl; } diff --git a/applications/test/reconstructedDistanceFunction/Make/options b/applications/test/reconstructedDistanceFunction/Make/options index c2d01bb839c..11a6714782c 100644 --- a/applications/test/reconstructedDistanceFunction/Make/options +++ b/applications/test/reconstructedDistanceFunction/Make/options @@ -1,11 +1,13 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/transportModels/geometricVoF/lnInclude EXE_LIBS = \ -lfiniteVolume \ + -lsurfMesh \ -lmeshTools \ -lsampling \ -lgeometricVoF diff --git a/applications/test/reconstructedDistanceFunction/Test-reconstructedDistanceFunction.C b/applications/test/reconstructedDistanceFunction/Test-reconstructedDistanceFunction.C index 612419f6fd5..efa5a33b454 100755 --- a/applications/test/reconstructedDistanceFunction/Test-reconstructedDistanceFunction.C +++ b/applications/test/reconstructedDistanceFunction/Test-reconstructedDistanceFunction.C @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) ); Info<< "create field phi\n" << endl; - surfaceScalarField phi = fvc::interpolate(U) & mesh.Sf(); + surfaceScalarField phi(fvc::interpolate(U) & mesh.Sf()); dictionary dict = mesh.solverDict(alpha1.name()); @@ -120,6 +120,7 @@ int main(int argc, char *argv[]) Info<< "Time " << runTime.cpuTimeIncrement() << endl; + #if 0 distFunc.constructRDF ( surf->interfaceCell(), @@ -128,6 +129,7 @@ int main(int argc, char *argv[]) 2, exchangeFields_ ); + #endif } runTime.write(); diff --git a/applications/test/refPtr/Test-refPtr.C b/applications/test/refPtr/Test-refPtr.C index 5a5b8726101..b2594d186c3 100644 --- a/applications/test/refPtr/Test-refPtr.C +++ b/applications/test/refPtr/Test-refPtr.C @@ -94,6 +94,8 @@ int main() } Info<< "\nEnd" << endl; + + return 0; } diff --git a/applications/test/scalarOps/Test-scalarOps.C b/applications/test/scalarOps/Test-scalarOps.C index 63df2131770..18d06fa9be5 100644 --- a/applications/test/scalarOps/Test-scalarOps.C +++ b/applications/test/scalarOps/Test-scalarOps.C @@ -72,7 +72,7 @@ void testDivide(const List<Tuple2<T, scalar>>& list) void testModulo(const List<Tuple2<scalar, scalar>>& list) { - const scalarModuloOp<> bop; + const scalarModuloOp<scalar> bop; for (const auto& pair : list) { diff --git a/applications/test/speed/scalarSpeed/Test-scalarSpeed.C b/applications/test/speed/scalarSpeed/Test-scalarSpeed.C index d6aa317209b..1e1307c775f 100644 --- a/applications/test/speed/scalarSpeed/Test-scalarSpeed.C +++ b/applications/test/speed/scalarSpeed/Test-scalarSpeed.C @@ -189,4 +189,6 @@ int main() Snull<< sf4[1] << endl << endl; } + + return 0; } diff --git a/applications/test/speed/vectorSpeed/Test-vectorSpeed.C b/applications/test/speed/vectorSpeed/Test-vectorSpeed.C index 2eaa85b40e4..2ab430d34a8 100644 --- a/applications/test/speed/vectorSpeed/Test-vectorSpeed.C +++ b/applications/test/speed/vectorSpeed/Test-vectorSpeed.C @@ -36,4 +36,6 @@ int main() Snull<< vf4[1] << endl << endl; } + + return 0; } diff --git a/applications/test/tmp/Test-tmp.C b/applications/test/tmp/Test-tmp.C index 52cbde670e6..366fcb10998 100644 --- a/applications/test/tmp/Test-tmp.C +++ b/applications/test/tmp/Test-tmp.C @@ -119,6 +119,8 @@ int main() } Info<< "\nEnd" << endl; + + return 0; } diff --git a/applications/test/wordRe/Test-wordRe.C b/applications/test/wordRe/Test-wordRe.C index f91258511da..bf6551e3a15 100644 --- a/applications/test/wordRe/Test-wordRe.C +++ b/applications/test/wordRe/Test-wordRe.C @@ -91,7 +91,7 @@ void exptl_reading(Istream& is, wordRes& list) bool testReadList_wordRes(const std::string& input) { - ITstream is("input", input); + ITstream is(input); wordRes list; exptl_reading(is, list); -- GitLab