Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
4a5071da
Commit
4a5071da
authored
3 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
rm formalistic unit test for good
parent
ed4a487e
No related branches found
No related tags found
1 merge request
!221
libParam: start active reading ...
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/UnitTests/Core/Sample/SampleProviderTest.cpp
+0
-108
0 additions, 108 deletions
Tests/UnitTests/Core/Sample/SampleProviderTest.cpp
with
0 additions
and
108 deletions
Tests/UnitTests/Core/Sample/SampleProviderTest.cpp
deleted
100644 → 0
+
0
−
108
View file @
ed4a487e
#include
"Sample/SampleBuilderEngine/SampleProvider.h"
#include
"Sample/Multilayer/MultiLayer.h"
#include
"Sample/SampleBuilderEngine/ISampleBuilder.h"
#include
"Tests/GTestWrapper/google_test.h"
#include
<memory>
class
SampleProviderTest
:
public
::
testing
::
Test
{
public:
//! Returns test multilayer.
static
std
::
unique_ptr
<
MultiLayer
>
testMultiLayer
(
double
length
)
{
std
::
unique_ptr
<
MultiLayer
>
result
(
new
MultiLayer
);
result
->
setCrossCorrLength
(
length
);
// used to check following cloning
return
result
;
}
//! Test class playing the role of SampleContainer's parent
class
TestSimulation
:
public
INode
{
public:
TestSimulation
()
{
setName
(
"TestSimulation"
);
registerChild
(
&
m_provider
);
}
void
accept
(
INodeVisitor
*
visitor
)
const
override
{
visitor
->
visit
(
this
);
}
std
::
vector
<
const
INode
*>
getChildren
()
const
override
{
return
m_provider
.
getChildren
();
}
SampleProvider
m_provider
;
};
//! Test sample builder
class
TestBuilder
:
public
ISampleBuilder
{
public:
explicit
TestBuilder
(
double
length
=
42.0
)
:
m_length
(
length
)
{
setName
(
"TestBuilder"
);
}
MultiLayer
*
buildSample
()
const
{
return
testMultiLayer
(
m_length
).
release
();
}
double
m_length
;
};
};
//! Test initial state, assignment operator.
TEST_F
(
SampleProviderTest
,
initialState
)
{
SampleProvider
provider
;
EXPECT_EQ
(
provider
.
sample
(),
nullptr
);
EXPECT_EQ
(
provider
.
getChildren
().
size
(),
0u
);
// setting the sample
provider
.
setSample
(
*
SampleProviderTest
::
testMultiLayer
(
42.0
));
EXPECT_EQ
(
provider
.
sample
()
->
crossCorrLength
(),
42.0
);
EXPECT_EQ
(
provider
.
sample
()
->
parent
(),
nullptr
);
}
//! Testing sample builder assignment.
TEST_F
(
SampleProviderTest
,
sampleBuilder
)
{
// Setting sample first
SampleProvider
provider
;
provider
.
setSample
(
*
SampleProviderTest
::
testMultiLayer
(
42.0
));
// Setting sample builder, original sample should gone.
std
::
shared_ptr
<
ISampleBuilder
>
builder
(
new
SampleProviderTest
::
TestBuilder
(
33.0
));
EXPECT_EQ
(
builder
.
use_count
(),
1
);
provider
.
setBuilder
(
builder
);
EXPECT_EQ
(
builder
.
use_count
(),
2
);
EXPECT_EQ
(
provider
.
sample
(),
nullptr
);
// Updating sample and checking if it is generated by sample builder
provider
.
updateSample
();
EXPECT_EQ
(
provider
.
sample
()
->
crossCorrLength
(),
33.0
);
}
//! Test parentship of container and sample in simulation context.
TEST_F
(
SampleProviderTest
,
sampleInSimulationContext
)
{
SampleProviderTest
::
TestSimulation
sim
;
SampleProvider
&
provider
=
sim
.
m_provider
;
provider
.
setSample
(
*
SampleProviderTest
::
testMultiLayer
(
42.0
));
// parent of container and parent of sample should be the same
EXPECT_EQ
(
provider
.
parent
(),
&
sim
);
EXPECT_EQ
(
provider
.
sample
()
->
parent
(),
&
sim
);
// children of container
ASSERT_EQ
(
provider
.
getChildren
().
size
(),
1u
);
EXPECT_EQ
(
provider
.
getChildren
()[
0
],
provider
.
sample
());
}
//! Test parentship of container and builder in simulation context.
TEST_F
(
SampleProviderTest
,
builderInSimulationContext
)
{
SampleProviderTest
::
TestSimulation
sim
;
SampleProvider
&
provider
=
sim
.
m_provider
;
std
::
shared_ptr
<
ISampleBuilder
>
builder
(
new
SampleProviderTest
::
TestBuilder
(
33.0
));
provider
.
setBuilder
(
builder
);
provider
.
updateSample
();
// provider's sample should not have neither parent nor children
EXPECT_EQ
(
provider
.
sample
()
->
parent
(),
nullptr
);
ASSERT_EQ
(
provider
.
getChildren
().
size
(),
1u
);
}
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