31#include <gtest/gtest.h>
71 return static_cast<long long>(
_getpid());
73 return static_cast<long long>(
getpid());
86 static std::atomic<unsigned long long>
counter{0};
87 const auto tick = std::chrono::steady_clock::now().time_since_epoch().count();
88 return std::filesystem::temp_directory_path()
89 / (name +
"_" + std::to_string(
static_cast<long long>(
tick)) +
90 "_" + std::to_string(process_id()) +
91 "_" + std::to_string(
counter++));
94 std::string
read_file(
const std::filesystem::path &path,
const bool binary =
false)
96 std::ifstream
in(path,
binary ? std::ios::binary :
std::ios::
in);
97 EXPECT_TRUE(
in.is_open()) <<
"read_file: cannot open '" << path.string() <<
"'";
98 std::ostringstream
out;
103 std::size_t
count_byte(
const std::string &s,
const unsigned char byte)
105 std::size_t
count = 0;
106 for (
const unsigned char c : s)
116 std::filesystem::remove_all(dir);
117 const auto path = dir /
"blinker.gif";
128 const std::string bytes =
read_file(path,
true);
134 std::filesystem::remove_all(dir);
140 std::filesystem::remove_all(dir);
141 const auto path = dir /
"player.html";
153 const std::string text =
read_file(path);
154 EXPECT_NE(text.find(
"<canvas id=\"view\""), std::string::npos);
155 EXPECT_NE(text.find(
"const frames = ["), std::string::npos);
156 EXPECT_NE(text.find(
"\"step\":0"), std::string::npos);
157 EXPECT_EQ(text.find(
"http://"), std::string::npos);
158 EXPECT_EQ(text.find(
"https://"), std::string::npos);
160 std::filesystem::remove_all(dir);
171 EXPECT_NE(sink.command().find(
"ffmpeg -y"), std::string::npos);
172 EXPECT_NE(sink.command().find(
"movie.mp4"), std::string::npos);
191 std::filesystem::remove_all(dir);
205 EXPECT_TRUE(std::filesystem::exists(dir /
"frame_00.png"));
206 EXPECT_TRUE(std::filesystem::exists(dir /
"frame_00.npy"));
207 EXPECT_TRUE(std::filesystem::exists(dir /
"trajectory.html"));
210 std::filesystem::remove_all(dir);
size_t size_t int32_t * out
Runtime ffmpeg sink for publication-quality CA video.
Directory-backed frame sinks for CA trajectories.
Animated GIF sink for cellular-automata trajectories.
Self-contained HTML trajectory player for CA frames.
NumPy .npy writer for CA frames.
Dependency-free PNG frame sink for cellular automata.
Optional live X11 viewer sink for CA simulations.
Fan-out sink that forwards every frame to several sinks.
Frame sink that streams PPM frames into ffmpeg.
Sink that buffers frames and writes an animated GIF on flush.
void accept(const std::size_t step, const Lattice &frame)
Collect one frame.
Sink that writes a self-contained HTML playback file.
void accept(const std::size_t step, const Lattice &frame)
Append one frame to the embedded trajectory.
Lattice that adds boundary-aware access on top of a storage.
Path-pattern sink that writes one .npy file per frame.
Path-pattern sink that writes one PNG file per accepted frame.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Itor find(const Itor &beg, const Itor &end, const T &value)
Find the first element equal to a value.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Default binary RGB mapper.
Options for Ffmpeg_Frame_Sink.
bool auto_start
start ffmpeg in the constructor
Options for animated GIF output.
unsigned delay_cs
frame delay in centiseconds
Options for generated HTML players.
std::string title
document title
Out-of-range neighbours behave as if the lattice ended.
Options for the live X11 viewer.
bool enabled
disable to force no-op behaviour
Cellular automata lattice with pluggable boundary policies.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).