22
22
#include " serialization/ksp_plugin.pb.h"
23
23
#include " testing_utilities/is_near.hpp"
24
24
#include " testing_utilities/serialization.hpp"
25
+ #include " testing_utilities/string_log_sink.hpp"
25
26
26
27
namespace principia {
27
28
namespace interface {
@@ -47,6 +48,7 @@ using testing_utilities::IsNear;
47
48
using testing_utilities::ReadFromBinaryFile;
48
49
using testing_utilities::ReadLinesFromBase64File;
49
50
using testing_utilities::ReadLinesFromHexadecimalFile;
51
+ using testing_utilities::StringLogSink;
50
52
using testing_utilities::WriteToBinaryFile;
51
53
using ::testing::AllOf;
52
54
using ::testing::ElementsAre;
@@ -61,43 +63,6 @@ using ::testing::internal::GetCapturedStderr;
61
63
const char preferred_compressor[] = " gipfeli" ;
62
64
const char preferred_encoder[] = " base64" ;
63
65
64
- class StringLogSink : google::LogSink {
65
- public:
66
- explicit StringLogSink (google::LogSeverity const minimal_severity)
67
- : minimal_severity_(minimal_severity) {
68
- google::AddLogSink (this );
69
- }
70
-
71
- ~StringLogSink () {
72
- google::RemoveLogSink (this );
73
- }
74
-
75
- void send (google::LogSeverity const severity,
76
- char const * const full_filename,
77
- char const * const base_filename,
78
- int const line,
79
- tm const * const tm_time,
80
- const char * const message,
81
- size_t const message_len) override {
82
- if (severity < minimal_severity_) {
83
- return ;
84
- }
85
- absl::MutexLock lock (&mutex_);
86
- absl::StrAppend (
87
- &string_,
88
- ToString (severity, base_filename, line, tm_time, message, message_len));
89
- }
90
-
91
- std::string& string () {
92
- return string_;
93
- }
94
-
95
- private:
96
- google::LogSeverity const minimal_severity_;
97
- absl::Mutex mutex_;
98
- std::string string_ GUARDED_BY (mutex_);
99
- };
100
-
101
66
class PluginCompatibilityTest : public testing ::Test {
102
67
protected:
103
68
PluginCompatibilityTest ()
@@ -375,6 +340,28 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
375
340
EXPECT_EQ (435'927 , history->Size ());
376
341
EXPECT_EQ (435'929 , psychohistory.Size ());
377
342
343
+ // Evaluate a point in each of the two segments.
344
+ EXPECT_THAT (history->EvaluateDegreesOfFreedom (" 1957-10-04T19:28:34" _TT),
345
+ Eq (DegreesOfFreedom<Barycentric>(
346
+ Barycentric::origin + Displacement<Barycentric>(
347
+ {+1.47513683827317657e+11 * Metre,
348
+ +2.88696086355042419e+10 * Metre,
349
+ +1.24740082262952404e+10 * Metre}),
350
+ Velocity<Barycentric>(
351
+ {-6.28845231836519179e+03 * (Metre / Second),
352
+ +2.34046542233168329e+04 * (Metre / Second),
353
+ +4.64410011408655919e+03 * (Metre / Second)}))));
354
+ EXPECT_THAT (psychohistory.EvaluateDegreesOfFreedom (" 1958-10-07T09:38:30" _TT),
355
+ Eq (DegreesOfFreedom<Barycentric>(
356
+ Barycentric::origin + Displacement<Barycentric>(
357
+ {+1.45814173315801941e+11 * Metre,
358
+ +3.45409490426372147e+10 * Metre,
359
+ +1.49445864962450924e+10 * Metre}),
360
+ Velocity<Barycentric>(
361
+ {-8.70708379504568074e+03 * (Metre / Second),
362
+ +2.61488327506437054e+04 * (Metre / Second),
363
+ +1.90319283138508908e+04 * (Metre / Second)}))));
364
+
378
365
// Serialize the history and psychohistory to a temporary file.
379
366
{
380
367
serialization::DiscreteTrajectory message;
0 commit comments