Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary_c-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Izzard, Robert Dr (Maths & Physics)
binary_c-python
Commits
410fd1ed
Commit
410fd1ed
authored
3 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
Updated tests to work with new master
parent
b523f812
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
binarycpython/tests/test_custom_logging.py
+5
-3
5 additions, 3 deletions
binarycpython/tests/test_custom_logging.py
binarycpython/tests/test_grid.py
+17
-15
17 additions, 15 deletions
binarycpython/tests/test_grid.py
with
22 additions
and
18 deletions
binarycpython/tests/test_custom_logging.py
+
5
−
3
View file @
410fd1ed
...
...
@@ -64,7 +64,8 @@ class test_custom_logging(unittest.TestCase):
input_2
=
'
Printf(
"
MY_STELLAR_DATA %g %g %g %g
\\
n
"
,((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));
'
output_2
=
binary_c_log_code
(
input_2
,
verbose
=
1
)
test_value_2
=
'
#pragma push_macro(
"
MAX
"
)
\n
#pragma push_macro(
"
MIN
"
)
\n
#undef MAX
\n
#undef MIN
\n
#include
"
binary_c.h
"
\n
#include
"
RLOF/RLOF_prototypes.h
"
\n\n
// add visibility __attribute__ ((visibility (
"
default
"
))) to it
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata);
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata)
\n
{
\n
// struct stardata_t * stardata = (struct stardata_t *)x;
\n
Printf(
"
MY_STELLAR_DATA %g %g %g %g
\\
n
"
,((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));;
\n
}
\n\n
#undef MAX
\n
#undef MIN
\n
#pragma pop_macro(
"
MIN
"
)
\n
#pragma pop_macro(
"
MAX
"
)
'
test_value_2
=
'
#pragma push_macro(
"
Max
"
)
\n
#pragma push_macro(
"
Min
"
)
\n
#undef Max
\n
#undef Min
\n
#include
"
binary_c.h
"
\n\n
// add visibility __attribute__ ((visibility (
"
default
"
))) to it
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata);
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata)
\n
{
\n
// struct stardata_t * stardata = (struct stardata_t *)x;
\n
Printf(
"
MY_STELLAR_DATA %g %g %g %g
\\
n
"
,((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));;
\n
}
\n\n
#undef Max
\n
#undef Min
\n
#pragma pop_macro(
"
Min
"
)
\n
#pragma pop_macro(
"
Max
"
)
'
self
.
assertEqual
(
output_2
,
test_value_2
,
...
...
@@ -81,7 +82,8 @@ class test_custom_logging(unittest.TestCase):
Tests to see if writing the code to a file and reading that out again is the same
"""
input_1
=
'
#pragma push_macro(
"
MAX
"
)
\n
#pragma push_macro(
"
MIN
"
)
\n
#undef MAX
\n
#undef MIN
\n
#include
"
binary_c.h
"
\n
#include
"
RLOF/RLOF_prototypes.h
"
\n\n
// add visibility __attribute__ ((visibility (
"
default
"
))) to it
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata);
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata)
\n
{
\n
// struct stardata_t * stardata = (struct stardata_t *)x;
\n
Printf(
"
MY_STELLAR_DATA %g %g %g %g
\\
n
"
,((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));;
\n
}
\n\n
#undef MAX
\n
#undef MIN
\n
#pragma pop_macro(
"
MIN
"
)
\n
#pragma pop_macro(
"
MAX
"
)
'
input_1
=
'
#pragma push_macro(
"
Max
"
)
\n
#pragma push_macro(
"
Min
"
)
\n
#undef Max
\n
#undef Min
\n
#include
"
binary_c.h
"
\n\n
// add visibility __attribute__ ((visibility (
"
default
"
))) to it
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata);
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata)
\n
{
\n
// struct stardata_t * stardata = (struct stardata_t *)x;
\n
Printf(
"
MY_STELLAR_DATA %g %g %g %g
\\
n
"
,((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));;
\n
}
\n\n
#undef Max
\n
#undef Min
\n
#pragma pop_macro(
"
Min
"
)
\n
#pragma pop_macro(
"
Max
"
)
'
binary_c_write_log_code
(
input_1
,
os
.
path
.
join
(
binary_c_temp_dir
,
"
test_binary_c_write_log_code.txt
"
),
...
...
@@ -161,7 +163,7 @@ class test_custom_logging(unittest.TestCase):
"""
#
input_1
=
'
#pragma push_macro(
"
MAX
"
)
\n
#pragma push_macro(
"
MIN
"
)
\n
#undef MAX
\n
#undef MIN
\n
#include
"
binary_c.h
"
\n
#include
"
RLOF/RLOF_prototypes.h
"
\n
\n
// add visibility __attribute__ ((visibility (
"
default
"
))) to it
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata);
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata)
\n
{
\n
// struct stardata_t * stardata = (struct stardata_t *)x;
\n
Printf(
"
MY_STELLAR_DATA %g %g %g %g
\\
n
"
,((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));;
\n
}
\n\n
#undef MAX
\n
#undef MIN
\n
#pragma pop_macro(
"
MIN
"
)
\n
#pragma pop_macro(
"
MAX
"
)
'
input_1
=
'
#pragma push_macro(
"
MAX
"
)
\n
#pragma push_macro(
"
MIN
"
)
\n
#undef MAX
\n
#undef MIN
\n
#include
"
binary_c.h
"
\n\n
// add visibility __attribute__ ((visibility (
"
default
"
))) to it
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata);
\n
void binary_c_API_function custom_output_function(struct stardata_t * stardata)
\n
{
\n
// struct stardata_t * stardata = (struct stardata_t *)x;
\n
Printf(
"
MY_STELLAR_DATA %g %g %g %g
\\
n
"
,((double)stardata->model.time),((double)stardata->star[0].mass),((double)stardata->model.probability),((double)stardata->model.dt));;
\n
}
\n\n
#undef MAX
\n
#undef MIN
\n
#pragma pop_macro(
"
MIN
"
)
\n
#pragma pop_macro(
"
MAX
"
)
'
output_1
=
create_and_load_logging_function
(
input_1
,
verbose
=
1
)
self
.
assertTrue
(
isinstance
(
output_1
[
0
],
int
),
msg
=
"
memaddr is not an int
"
)
...
...
This diff is collapsed.
Click to expand it.
binarycpython/tests/test_grid.py
+
17
−
15
View file @
410fd1ed
...
...
@@ -287,7 +287,9 @@ class test_Population(unittest.TestCase):
if
binary_c_version_info
[
"
macros
"
][
"
NUCSYN
"
]
==
"
on
"
:
self
.
assertIsNotNone
(
binary_c_version_info
[
"
isotopes
"
])
self
.
assertIsNotNone
(
binary_c_version_info
[
"
nucleosynthesis_sources
"
])
if
binary_c_version_info
[
"
macros
"
][
"
NUCSYN_ID_SOURCES
"
]
==
"
on
"
:
self
.
assertIsNotNone
(
binary_c_version_info
[
"
nucleosynthesis_sources
"
])
def
test__return_binary_c_defaults
(
self
):
with
Capturing
()
as
output
:
...
...
@@ -656,8 +658,8 @@ class test_grid_evolve(unittest.TestCase):
remove_file
(
output_name
)
def
test_grid_evolve_with_condition_error
(
self
):
#
with Capturing() as output:
self
.
_test_grid_evolve_with_condition_error
()
with
Capturing
()
as
output
:
self
.
_test_grid_evolve_with_condition_error
()
def
_test_grid_evolve_with_condition_error
(
self
):
"""
...
...
@@ -671,18 +673,18 @@ class test_grid_evolve(unittest.TestCase):
test_pop
.
set
(
failed_systems_threshold
=
4
)
CUSTOM_LOGGING_STRING_WITH_EXIT
=
"""
Exit_binary_c(BINARY_C_NORMAL_EXIT,
"
testing exits. This is part of the testing, don
'
t worry
"
);
Printf(
"
TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g
\\
n
"
,
//
stardata->model.time, // 1
// masses
stardata->common.zero_age.mass[0], //
stardata->common.zero_age.mass[1], //
stardata->star[0].mass,
stardata->star[1].mass
);
Exit_binary_c(BINARY_C_NORMAL_EXIT,
"
testing exits. This is part of the testing, don
'
t worry
"
);
Printf(
"
TEST_CUSTOM_LOGGING_1 %30.12e %g %g %g %g
\\
n
"
,
//
stardata->model.time, // 1
// masses
stardata->common.zero_age.mass[0], //
stardata->common.zero_age.mass[1], //
stardata->star[0].mass,
stardata->star[1].mass
);
"""
test_pop
.
set
(
C_logging_code
=
CUSTOM_LOGGING_STRING_WITH_EXIT
)
...
...
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