Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
Gauthier Quesnel
irritator
Commits
bdcda48a
Commit
bdcda48a
authored
Apr 12, 2021
by
Gauthier Quesnel
Browse files
test: fix data in the generator source
parent
33b0e646
Pipeline
#30702
passed with stage
in 1 minute and 35 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/CMakeLists.txt
View file @
bdcda48a
...
...
@@ -58,7 +58,7 @@ install(DIRECTORY include/irritator
${
CMAKE_INSTALL_INCLUDEDIR
}
/irritator-
${
PROJECT_VERSION_MAJOR
}
.
${
PROJECT_VERSION_MINOR
}
)
function
(
irritator_add_test test_name
)
add_executable
(
${
test_name
}
${
ARGN
}
)
add_executable
(
${
test_name
}
${
ARGN
}
"include/irritator/external_source.hpp"
)
set_target_properties
(
${
test_name
}
PROPERTIES
COMPILE_DEFINITIONS EXAMPLES_DIR=\"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test\"
...
...
lib/test/public-api.cpp
View file @
bdcda48a
...
...
@@ -4,6 +4,7 @@
#include
<irritator/core.hpp>
#include
<irritator/examples.hpp>
#include
<irritator/external_source.hpp>
#include
<irritator/io.hpp>
#include
<boost/ut.hpp>
...
...
@@ -11,6 +12,7 @@
#include
<fmt/format.h>
#include
<iostream>
#include
<random>
#include
<sstream>
#include
<cstdio>
...
...
@@ -948,23 +950,31 @@ main()
expect
(
sim
.
external_sources
.
can_alloc
(
1
));
double
data
[
2
]
=
{
0.0
,
1.0
};
{
auto
&
src
=
sim
.
external_sources
.
alloc
();
double
data
=
0.0
;
src
.
data
=
&
data
;
src
.
data
=
&
data
[
0
];
src
.
index
=
0
;
src
.
size
=
1
;
src
.
type
=
irt
::
external_source
::
source_type
::
constant
;
src
.
expand
=
[](
auto
&
src
)
{
src
.
index
=
0
;
return
true
;
};
gen
.
default_value_source_id
=
sim
.
external_sources
.
get_id
(
src
);
}
{
auto
&
src
=
sim
.
external_sources
.
alloc
();
double
data
=
1.0
;
src
.
data
=
&
data
;
src
.
data
=
&
data
[
1
];
src
.
index
=
0
;
src
.
size
=
1
;
src
.
type
=
irt
::
external_source
::
source_type
::
constant
;
src
.
expand
=
[](
auto
&
src
)
{
src
.
index
=
0
;
return
true
;
};
gen
.
default_lambda_source_id
=
sim
.
external_sources
.
get_id
(
src
);
}
...
...
@@ -3077,4 +3087,25 @@ main()
irt
::
is_fatal_breakpoint
=
true
;
};
"external_source"
_test
=
[]
{
std
::
error_code
ec
;
std
::
stringstream
ofs_b
;
std
::
stringstream
ofs_t
;
std
::
default_random_engine
gen
(
1234
);
std
::
poisson_distribution
dist
(
4.0
);
irt
::
source
::
generate_random_file
(
ofs_b
,
gen
,
dist
,
1024
,
irt
::
source
::
random_file_type
::
binary
);
auto
str_b
=
ofs_b
.
str
();
expect
(
str_b
.
size
()
==
1024
*
8
);
irt
::
source
::
generate_random_file
(
ofs_t
,
gen
,
dist
,
1024
,
irt
::
source
::
random_file_type
::
text
);
auto
str_t
=
ofs_b
.
str
();
expect
(
str_t
.
size
()
>
1024
*
2
);
};
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment