Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirtualFluids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iRMB
VirtualFluids
Commits
370e160f
Commit
370e160f
authored
2 years ago
by
Anna Wellmann
Browse files
Options
Downloads
Patches
Plain Diff
Refactor the new tests
parent
16c83ab9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!181
Viscosity check
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/basics/tests/testUtilities.h
+2
-0
2 additions, 0 deletions
src/basics/tests/testUtilities.h
src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
+40
-42
40 additions, 42 deletions
src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
with
42 additions
and
42 deletions
src/basics/tests/testUtilities.h
+
2
−
0
View file @
370e160f
#ifndef TESTUTILITIES_H
#define TESTUTILITIES_H
#include
<gmock/gmock.h>
inline
auto
RealEq
=
[](
auto
value
)
{
#ifdef VF_DOUBLE_ACCURACY
return
testing
::
DoubleEq
(
value
);
...
...
This diff is collapsed.
Click to expand it.
src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
+
40
−
42
View file @
370e160f
#include
<gmock/gmock.h>
#include
"basics/tests/testUtilities.h"
#include
<gmock/gmock.h>
#include
<filesystem>
#include
<gtest/gtest.h>
#include
<iostream>
#include
<string>
#include
"Parameter.h"
#include
"basics/config/ConfigurationFile.h"
TEST
(
ParameterTest
,
passingEmptyFileWithoutPath_ShouldNotThrow
)
{
// assuming that the config files is stored parallel to this file.
...
...
@@ -37,7 +37,9 @@ TEST(ParameterTest, check_all_Parameter_CanBePassedToConstructor)
// test optional parameter
EXPECT_THAT
(
para
.
getOutputPath
(),
testing
::
Eq
(
"/output/path/"
));
EXPECT_THAT
(
para
.
getGridPath
(),
testing
::
Eq
(
"/path/to/grid/"
));
// ... all grid files (e.g. multi-gpu/ multi-level) could be tested as well
EXPECT_THAT
(
para
.
getGridPath
(),
testing
::
Eq
(
"/path/to/grid/"
));
// ... all grid files (e.g. multi-gpu/ multi-level) could be tested as well
EXPECT_THAT
(
para
.
getgeoVec
(),
testing
::
Eq
(
"/path/to/grid/geoVec.dat"
));
EXPECT_THAT
(
para
.
getMaxDev
(),
testing
::
Eq
(
2
));
EXPECT_THAT
(
para
.
getDevices
(),
testing
::
ElementsAreArray
({
2
,
3
}));
...
...
@@ -163,7 +165,7 @@ TEST(ParameterTest, setGridPathOverridesDefaultGridPath)
Parameter
para
(
2
,
1
);
para
.
setGridPath
(
"gridPathTest"
);
EXPECT_THAT
(
para
.
getGridPath
(),
testing
::
Eq
(
"gridPathTest/1/"
));
EXPECT_THAT
(
para
.
getGridPath
(),
testing
::
Eq
(
"gridPathTest/1/"
));
EXPECT_THAT
(
para
.
getConcentration
(),
testing
::
Eq
(
"gridPathTest/1/conc.dat"
));
}
...
...
@@ -177,9 +179,8 @@ TEST(ParameterTest, setGridPathOverridesConfigFile)
auto
para
=
Parameter
(
2
,
0
,
&
config
);
para
.
setGridPath
(
"gridPathTest"
);
EXPECT_THAT
(
para
.
getGridPath
(),
testing
::
Eq
(
"gridPathTest/0/"
));
EXPECT_THAT
(
para
.
getGridPath
(),
testing
::
Eq
(
"gridPathTest/0/"
));
EXPECT_THAT
(
para
.
getConcentration
(),
testing
::
Eq
(
"gridPathTest/0/conc.dat"
));
}
TEST
(
ParameterTest
,
userMissedSlash
)
...
...
@@ -189,7 +190,6 @@ TEST(ParameterTest, userMissedSlash)
EXPECT_THAT
(
para
.
getGridPath
(),
testing
::
Eq
(
"gridPathTest/"
));
EXPECT_THAT
(
para
.
getConcentration
(),
testing
::
Eq
(
"gridPathTest/conc.dat"
));
}
TEST
(
ParameterTest
,
userMissedSlashMultiGPU
)
...
...
@@ -201,87 +201,85 @@ TEST(ParameterTest, userMissedSlashMultiGPU)
EXPECT_THAT
(
para
.
getConcentration
(),
testing
::
Eq
(
"gridPathTest/0/conc.dat"
));
}
TEST
(
ParameterTest
,
Cumula
n
tK17
_VelocityIsTooHigh_expectWarning
)
class
ParameterTestCumulat
n
K17
:
public
testing
::
Test
{
testing
::
internal
::
CaptureStdout
();
protected:
void
SetUp
()
override
{
}
bool
stdoutContainsWarning
()
{
std
::
string
output
=
testing
::
internal
::
GetCapturedStdout
();
return
output
.
find
(
"warning"
)
!=
std
::
string
::
npos
;
}
Parameter
para
;
};
TEST_F
(
ParameterTestCumulatnK17
,
CumulantK17_VelocityIsTooHigh_expectWarning
)
{
para
.
setVelocityLB
(
0.11
);
para
.
setMainKernel
(
"CumulantK17"
);
testing
::
internal
::
CaptureStdout
();
para
.
initLBMSimulationParameter
();
std
::
string
output
=
testing
::
internal
::
GetCapturedStdout
();
EXPECT_FALSE
(
output
.
find
(
"warning"
)
==
std
::
string
::
npos
);
EXPECT_TRUE
(
stdoutContainsWarning
());
}
TEST
(
ParameterTest
,
CumulantK17_VelocityIsOk_expectNoWarning
)
TEST
_F
(
ParameterTest
CumulatnK17
,
CumulantK17_VelocityIsOk_expectNoWarning
)
{
testing
::
internal
::
CaptureStdout
();
Parameter
para
;
para
.
setVelocityLB
(
0.09
);
para
.
setMainKernel
(
"CumulantK17"
);
testing
::
internal
::
CaptureStdout
();
para
.
initLBMSimulationParameter
();
std
::
string
output
=
testing
::
internal
::
GetCapturedStdout
();
EXPECT_TRUE
(
output
.
find
(
"warning"
)
==
std
::
string
::
npos
);
EXPECT_FALSE
(
stdoutContainsWarning
());
}
TEST
(
ParameterTest
,
NotCumulantK17_VelocityIsTooHigh_expectNoWarning
)
TEST
_F
(
ParameterTest
CumulatnK17
,
NotCumulantK17_VelocityIsTooHigh_expectNoWarning
)
{
testing
::
internal
::
CaptureStdout
();
Parameter
para
;
para
.
setVelocityLB
(
42
);
para
.
setMainKernel
(
"K"
);
testing
::
internal
::
CaptureStdout
();
para
.
initLBMSimulationParameter
();
std
::
string
output
=
testing
::
internal
::
GetCapturedStdout
();
EXPECT_TRUE
(
output
.
find
(
"warning"
)
==
std
::
string
::
npos
);
EXPECT_FALSE
(
stdoutContainsWarning
());
}
TEST
(
ParameterTest
,
CumulantK17_ViscosityIsTooHigh_expectWarning
)
TEST_F
(
ParameterTestCumulatnK17
,
CumulantK17_ViscosityIsTooHigh_expectWarning
)
{
testing
::
internal
::
CaptureStdout
();
Parameter
para
;
para
.
setViscosityLB
(
0.024
);
para
.
setMainKernel
(
"CumulantK17"
);
testing
::
internal
::
CaptureStdout
();
para
.
initLBMSimulationParameter
();
std
::
string
output
=
testing
::
internal
::
GetCapturedStdout
();
EXPECT_FALSE
(
output
.
find
(
"warning"
)
==
std
::
string
::
npos
);
EXPECT_TRUE
(
stdoutContainsWarning
());
}
TEST
(
ParameterTest
,
CumulantK17_ViscosityIsOk_expectNoWarning
)
TEST
_F
(
ParameterTest
CumulatnK17
,
CumulantK17_ViscosityIsOk_expectNoWarning
)
{
testing
::
internal
::
CaptureStdout
();
Parameter
para
;
para
.
setViscosityLB
(
0.023
);
para
.
setMainKernel
(
"CumulantK17"
);
testing
::
internal
::
CaptureStdout
();
para
.
initLBMSimulationParameter
();
std
::
string
output
=
testing
::
internal
::
GetCapturedStdout
();
EXPECT_TRUE
(
output
.
find
(
"warning"
)
==
std
::
string
::
npos
);
EXPECT_FALSE
(
stdoutContainsWarning
());
}
TEST
(
ParameterTest
,
NotCumulantK17_ViscosityIsTooHigh_expectNoWarning
)
TEST
_F
(
ParameterTest
CumulatnK17
,
NotCumulantK17_ViscosityIsTooHigh_expectNoWarning
)
{
testing
::
internal
::
CaptureStdout
();
Parameter
para
;
para
.
setViscosityLB
(
10
);
para
.
setMainKernel
(
"K"
);
testing
::
internal
::
CaptureStdout
();
para
.
initLBMSimulationParameter
();
std
::
string
output
=
testing
::
internal
::
GetCapturedStdout
();
EXPECT_TRUE
(
output
.
find
(
"warning"
)
==
std
::
string
::
npos
);
EXPECT_FALSE
(
stdoutContainsWarning
());
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment