-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
simulator_status_test.cc
39 lines (31 loc) · 1.32 KB
/
simulator_status_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "drake/systems/analysis/simulator_status.h"
#include <gtest/gtest.h>
namespace drake {
namespace systems {
namespace {
GTEST_TEST(SimulatorStatusTest, ConstructionAndRetrieval) {
const SystemBase* dummy = reinterpret_cast<const SystemBase*>(0x1234);
SimulatorStatus status(1.25); // Always constructed with a boundary_time.
// Default is that the status reached the boundary time.
EXPECT_EQ(status.boundary_time(), 1.25);
EXPECT_EQ(status.return_time(), status.boundary_time());
EXPECT_EQ(status.reason(), SimulatorStatus::kReachedBoundaryTime);
EXPECT_EQ(status.system(), nullptr);
EXPECT_EQ(status.message(), std::string());
status.SetReachedTermination(1., dummy, "Hello there");
EXPECT_EQ(status.boundary_time(), 1.25);
EXPECT_EQ(status.return_time(), 1.);
EXPECT_EQ(status.reason(), SimulatorStatus::kReachedTerminationCondition);
EXPECT_EQ(status.system(), dummy);
EXPECT_EQ(status.message(), std::string("Hello there"));
}
GTEST_TEST(SimulatorStatusTest, CopyConstruction) {
const SystemBase* dummy = reinterpret_cast<const SystemBase*>(0x1234);
SimulatorStatus status(1.0);
status.SetEventHandlerFailed(0.5, dummy, "test message");
SimulatorStatus copy_status(status);
EXPECT_TRUE(copy_status.IsIdenticalStatus(status));
}
} // namespace
} // namespace systems
} // namespace drake