summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-03 13:06:53 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-04 06:58:13 +0100
commit23a7a6defc0f30f8d053ae4ec65ed8046ce9f4e5 (patch)
tree80953de856eced8b2adbb35c9b77e3aa22b688b9 /test
parent12dddee0662ff9eb3ecaf655db8da22e33e9eb4f (diff)
test/critter,src/timer: wip!
Diffstat (limited to 'test')
-rw-r--r--test/critter.cpp23
-rw-r--r--test/serializer.cpp3
2 files changed, 15 insertions, 11 deletions
diff --git a/test/critter.cpp b/test/critter.cpp
index 0a959317..4e215ab2 100644
--- a/test/critter.cpp
+++ b/test/critter.cpp
@@ -22,11 +22,10 @@ template<typename F>
void run(StringView name, const F& make_dt, critter& npc, const Ns max_time,
const point start, const rotation r,
const point end, const Ns expected_time,
- const uint32_t fuzz_pixels, const Ns fuzz_time)
+ const uint32_t fuzz_pixels, const Ns fuzz_time, bool no_crash = false)
{
constexpr uint32_t max_steps = 10'000;
- const bool verbose = is_log_verbose();
- fm_assert(max_time < Second*200);
+ fm_assert(max_time < Second*300);
auto index = npc.index();
npc.teleport_to(index, start, rotation_COUNT);
@@ -41,26 +40,32 @@ void run(StringView name, const F& make_dt, critter& npc, const Ns max_time,
uint32_t i;
bool stopped = false;
+ constexpr auto bar = Second*1000;
+
for (i = 0; i <= max_steps; i++)
{
auto dt = Ns{make_dt()};
- fm_assert(dt <= Ns(1e9));
+ fm_assert(dt == Millisecond * 100);
+ const auto pos = npc.position();
+ Debug{} << "-" << pos << colon(',') << "time" << time << Debug::nospace << ", dt" << dt;
+ fm_assert(dt >= Millisecond*1e-1);
+ fm_assert(dt <= Second * 1000);
npc.update_movement(index, dt, r);
time += dt;
- const auto pos = npc.position();
if (pos == last_pos)
{
stopped = true;
break;
}
last_pos = pos;
- Debug{} << "-" << pos << colon(',') << time;
if (time > max_time) [[unlikely]]
{
- if (verbose)
- Error{&std::cerr} << "timeout:" << max_time << "reached!";
- fm_EMIT_ABORT();
+ Error{&std::cerr} << "timeout:" << max_time << "reached!";
+ if (no_crash)
+ return;
+ else
+ fm_EMIT_ABORT();
}
fm_assert(i != max_steps);
diff --git a/test/serializer.cpp b/test/serializer.cpp
index 61a5d509..e85f7892 100644
--- a/test/serializer.cpp
+++ b/test/serializer.cpp
@@ -53,8 +53,7 @@ chunk& test_app::make_test_chunk(world& w, chunk_coords_ ch)
auto& e = *w.make_object<scenery>(w.make_id(), {ch, {K+3, K+1}}, door);
const auto index = e.index();
const auto end = e.atlas->info().nframes-1;
- constexpr auto second = Ns(1e9);
- constexpr auto dt = Ns{second.stamp / 60};
+ constexpr Ns dt = Second / 60;
fm_assert(e.frame == end);
{ auto& x = std::get<door_scenery>(e.subtype);
fm_assert(!x.active);