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
b2126110
Commit
b2126110
authored
3 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
split into two tests
parent
86c38f21
No related branches found
No related tags found
1 merge request
!524
improve export-to-Python tests
Pipeline
#51620
passed
3 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Functional/PyEmbedded/Tests.cpp
+24
-12
24 additions, 12 deletions
Tests/Functional/PyEmbedded/Tests.cpp
with
24 additions
and
12 deletions
Tests/Functional/PyEmbedded/Tests.cpp
+
24
−
12
View file @
b2126110
...
@@ -361,14 +361,12 @@ TEST_F(PyEmbedded, EmbeddedMultiLayer)
...
@@ -361,14 +361,12 @@ TEST_F(PyEmbedded, EmbeddedMultiLayer)
}
}
//! We use one of our standard sample builders to build a sample, then generate Python snippet
//! We use one of our standard sample builders to build a sample, then generate Python snippet
//! using our standard ExportToPython machinery.
//! using our standard ExportToPython machinery. Ditto for a cloned sample.
//! Given snippet is compiled and executed in embedded interpretor. Resulting multi layer
//! Two exported code snippets must be identical.
//! is casted back to C++ object and used again, to generate code snippet.
//! Two code snippets must be identical.
TEST_F
(
PyEmbedded
,
ExportToPython
AndBack
)
TEST_F
(
PyEmbedded
,
CloneAnd
ExportToPython
)
{
{
std
::
unique_ptr
<
MultiLayer
>
sample1
(
ExemplarySamples
::
create
CylindersAndPrism
s
());
std
::
unique_ptr
<
MultiLayer
>
sample1
(
ExemplarySamples
::
create
MultiLayerWithNCRoughnes
s
());
const
std
::
string
code1
=
Py
::
Export
::
sampleCode
(
*
sample1
);
const
std
::
string
code1
=
Py
::
Export
::
sampleCode
(
*
sample1
);
std
::
cout
<<
"Test ExportToPythonAndBack: code1:
\n
"
<<
code1
<<
std
::
endl
;
std
::
cout
<<
"Test ExportToPythonAndBack: code1:
\n
"
<<
code1
<<
std
::
endl
;
...
@@ -380,17 +378,31 @@ TEST_F(PyEmbedded, ExportToPythonAndBack)
...
@@ -380,17 +378,31 @@ TEST_F(PyEmbedded, ExportToPythonAndBack)
else
else
std
::
cout
<<
"Test ExportToPythonAndBack: code2 = code1"
<<
std
::
endl
;
std
::
cout
<<
"Test ExportToPythonAndBack: code2 = code1"
<<
std
::
endl
;
EXPECT_TRUE
(
code2
==
code1
);
EXPECT_TRUE
(
code2
==
code1
);
}
//! We use one of our standard sample builders to build a sample, then generate Python snippet
//! using our standard ExportToPython machinery.
//! Given snippet is compiled and executed in embedded interpretor. Resulting multi layer
//! is casted back to C++ object and used again, to generate code snippet.
//! Two code snippets must be identical.
TEST_F
(
PyEmbedded
,
ExportToPythonAndBack
)
{
std
::
unique_ptr
<
MultiLayer
>
sample1
(
ExemplarySamples
::
createCylindersAndPrisms
());
const
std
::
string
code1
=
Py
::
Export
::
sampleCode
(
*
sample1
);
std
::
cout
<<
"Test ExportToPythonAndBack: code1:
\n
"
<<
code1
<<
std
::
endl
;
const
std
::
string
snippet
=
const
std
::
string
snippet
=
"import bornagain as ba
\n
"
+
Py
::
Fmt
::
printImportedSymbols
(
code1
)
+
"
\n\n
"
+
code1
;
"import bornagain as ba
\n
"
+
Py
::
Fmt
::
printImportedSymbols
(
code1
)
+
"
\n\n
"
+
code1
;
const
auto
sample
3
=
const
auto
sample
2
=
Py
::
Import
::
createFromPython
(
snippet
,
"get_sample"
,
BABuild
::
buildLibDir
());
Py
::
Import
::
createFromPython
(
snippet
,
"get_sample"
,
BABuild
::
buildLibDir
());
const
std
::
string
code
3
=
Py
::
Export
::
sampleCode
(
*
sample
3
);
const
std
::
string
code
2
=
Py
::
Export
::
sampleCode
(
*
sample
2
);
if
(
code
3
!=
code1
)
if
(
code
2
!=
code1
)
std
::
cout
<<
"Test ExportToPythonAndBack: code
3
:
\n
"
<<
code
3
<<
std
::
endl
;
std
::
cout
<<
"Test ExportToPythonAndBack: code
2
:
\n
"
<<
code
2
<<
std
::
endl
;
else
else
std
::
cout
<<
"Test ExportToPythonAndBack: code
3
= code1"
<<
std
::
endl
;
std
::
cout
<<
"Test ExportToPythonAndBack: code
2
= code1"
<<
std
::
endl
;
EXPECT_TRUE
(
code
3
==
code1
);
EXPECT_TRUE
(
code
2
==
code1
);
}
}
//! Retrieves list of functions from the imported script and checks, that there is
//! Retrieves list of functions from the imported script and checks, that there is
...
...
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