Skip to content

Commit 3f1dc2e

Browse files
committed
Fix formatting
Signed-off-by: JCW <[email protected]>
1 parent 1fb569a commit 3f1dc2e

File tree

1 file changed

+161
-66
lines changed

1 file changed

+161
-66
lines changed

src/tests/libxrpl/basics/log.cpp

Lines changed: 161 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919

2020
#include <xrpl/basics/Log.h>
2121

22-
#include <doctest/doctest.h>
2322
#include <boost/json.hpp>
2423

25-
#include <numbers>
24+
#include <doctest/doctest.h>
25+
2626
#include <iostream>
27+
#include <numbers>
2728

2829
using namespace ripple;
2930

@@ -178,9 +179,12 @@ TEST_CASE("Global attributes")
178179
CHECK(jsonLog.as_object().contains("GlobalParams"));
179180
CHECK(jsonLog.as_object()["GlobalParams"].is_object());
180181
CHECK(jsonLog.as_object()["GlobalParams"].as_object().contains("Field1"));
181-
CHECK(jsonLog.as_object()["GlobalParams"].as_object()["Field1"].is_string());
182182
CHECK(
183-
jsonLog.as_object()["GlobalParams"].as_object()["Field1"].get_string() == "Value1");
183+
jsonLog.as_object()["GlobalParams"].as_object()["Field1"].is_string());
184+
CHECK(
185+
jsonLog.as_object()["GlobalParams"]
186+
.as_object()["Field1"]
187+
.get_string() == "Value1");
184188
beast::Journal::disableStructuredJournal();
185189
}
186190

@@ -207,13 +211,20 @@ TEST_CASE("Global attributes inheritable")
207211

208212
CHECK(jsonLog.is_object());
209213
CHECK(jsonLog.as_object()["GlobalParams"].as_object().contains("Field1"));
210-
CHECK(jsonLog.as_object()["GlobalParams"].as_object()["Field1"].is_string());
211214
CHECK(
212-
jsonLog.as_object()["GlobalParams"].as_object()["Field1"].get_string() == "Value1");
215+
jsonLog.as_object()["GlobalParams"].as_object()["Field1"].is_string());
216+
CHECK(
217+
jsonLog.as_object()["GlobalParams"]
218+
.as_object()["Field1"]
219+
.get_string() == "Value1");
213220
CHECK(
214-
jsonLog.as_object()["JournalParams"].as_object()["Field1"].get_string() == "Value3");
221+
jsonLog.as_object()["JournalParams"]
222+
.as_object()["Field1"]
223+
.get_string() == "Value3");
215224
CHECK(
216-
jsonLog.as_object()["JournalParams"].as_object()["Field2"].get_string() == "Value2");
225+
jsonLog.as_object()["JournalParams"]
226+
.as_object()["Field2"]
227+
.get_string() == "Value2");
217228
beast::Journal::disableStructuredJournal();
218229
}
219230

@@ -334,18 +345,26 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogFields")
334345
CHECK(logValue.as_object()["MessageParams"].is_object());
335346
CHECK(logValue.as_object()["Message"].is_string());
336347

337-
CHECK(logValue.as_object()["MessageParams"].as_object().contains("Function"));
348+
CHECK(
349+
logValue.as_object()["MessageParams"].as_object().contains("Function"));
338350
CHECK(logValue.as_object()["MessageParams"].as_object().contains("File"));
339351
CHECK(logValue.as_object()["MessageParams"].as_object().contains("Line"));
340-
CHECK(logValue.as_object()["MessageParams"].as_object().contains("ThreadId"));
352+
CHECK(
353+
logValue.as_object()["MessageParams"].as_object().contains("ThreadId"));
341354
CHECK(logValue.as_object()["MessageParams"].as_object().contains("Level"));
342355
CHECK(logValue.as_object()["MessageParams"].as_object().contains("Time"));
343356

344-
CHECK(logValue.as_object()["MessageParams"].as_object()["Function"].is_string());
345-
CHECK(logValue.as_object()["MessageParams"].as_object()["File"].is_string());
346-
CHECK(logValue.as_object()["MessageParams"].as_object()["Line"].is_number());
357+
CHECK(logValue.as_object()["MessageParams"]
358+
.as_object()["Function"]
359+
.is_string());
360+
CHECK(
361+
logValue.as_object()["MessageParams"].as_object()["File"].is_string());
362+
CHECK(
363+
logValue.as_object()["MessageParams"].as_object()["Line"].is_number());
347364

348-
CHECK(logValue.as_object()["Message"].get_string() == std::string{"true Test false"});
365+
CHECK(
366+
logValue.as_object()["Message"].get_string() ==
367+
std::string{"true Test false"});
349368
}
350369

351370
TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
@@ -359,7 +378,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
359378
CHECK(ec == boost::system::errc::success);
360379

361380
CHECK(
362-
logValue.as_object()["MessageParams"].as_object()["Level"].get_string() ==
381+
logValue.as_object()["MessageParams"]
382+
.as_object()["Level"]
383+
.get_string() ==
363384
beast::severities::to_string(beast::severities::kTrace));
364385
}
365386

@@ -372,7 +393,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
372393
CHECK(ec == boost::system::errc::success);
373394

374395
CHECK(
375-
logValue.as_object()["MessageParams"].as_object()["Level"].get_string() ==
396+
logValue.as_object()["MessageParams"]
397+
.as_object()["Level"]
398+
.get_string() ==
376399
beast::severities::to_string(beast::severities::kDebug));
377400
}
378401

@@ -385,7 +408,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
385408
CHECK(ec == boost::system::errc::success);
386409

387410
CHECK(
388-
logValue.as_object()["MessageParams"].as_object()["Level"].get_string() ==
411+
logValue.as_object()["MessageParams"]
412+
.as_object()["Level"]
413+
.get_string() ==
389414
beast::severities::to_string(beast::severities::kInfo));
390415
}
391416

@@ -398,7 +423,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
398423
CHECK(ec == boost::system::errc::success);
399424

400425
CHECK(
401-
logValue.as_object()["MessageParams"].as_object()["Level"].get_string() ==
426+
logValue.as_object()["MessageParams"]
427+
.as_object()["Level"]
428+
.get_string() ==
402429
beast::severities::to_string(beast::severities::kWarning));
403430
}
404431

@@ -411,7 +438,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
411438
CHECK(ec == boost::system::errc::success);
412439

413440
CHECK(
414-
logValue.as_object()["MessageParams"].as_object()["Level"].get_string() ==
441+
logValue.as_object()["MessageParams"]
442+
.as_object()["Level"]
443+
.get_string() ==
415444
beast::severities::to_string(beast::severities::kError));
416445
}
417446

@@ -424,7 +453,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogLevels")
424453
CHECK(ec == boost::system::errc::success);
425454

426455
CHECK(
427-
logValue.as_object()["MessageParams"].as_object()["Level"].get_string() ==
456+
logValue.as_object()["MessageParams"]
457+
.as_object()["Level"]
458+
.get_string() ==
428459
beast::severities::to_string(beast::severities::kFatal));
429460
}
430461
}
@@ -438,7 +469,9 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogStream")
438469
CHECK(ec == boost::system::errc::success);
439470

440471
CHECK(
441-
logValue.as_object()["MessageParams"].as_object()["Level"].get_string() ==
472+
logValue.as_object()["MessageParams"]
473+
.as_object()["Level"]
474+
.get_string() ==
442475
beast::severities::to_string(beast::severities::kError));
443476
}
444477

@@ -448,23 +481,31 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogParams")
448481
<< log::param(
449482
"Field2",
450483
std::numeric_limits<std::uint64_t>::max())
451-
<< ", "
452-
<< log::param("Field3", std::numbers::pi);
484+
<< ", " << log::param("Field3", std::numbers::pi);
453485

454486
boost::system::error_code ec;
455487
auto logValue = boost::json::parse(stream().str(), ec);
456488
CHECK(ec == boost::system::errc::success);
457489

458490
CHECK(logValue.as_object()["MessageParams"].is_object());
459-
CHECK(logValue.as_object()["MessageParams"].as_object()["Field1"].is_number());
460-
CHECK(logValue.as_object()["MessageParams"].as_object()["Field1"].get_int64() == 1);
461-
CHECK(logValue.as_object()["MessageParams"].as_object()["Field2"].is_number());
491+
CHECK(logValue.as_object()["MessageParams"]
492+
.as_object()["Field1"]
493+
.is_number());
462494
CHECK(
463-
logValue.as_object()["MessageParams"].as_object()["Field2"].get_uint64() ==
464-
std::numeric_limits<std::uint64_t>::max());
495+
logValue.as_object()["MessageParams"]
496+
.as_object()["Field1"]
497+
.get_int64() == 1);
498+
CHECK(logValue.as_object()["MessageParams"]
499+
.as_object()["Field2"]
500+
.is_number());
465501
CHECK(
466-
logValue.as_object()["MessageParams"].as_object()["Field3"].get_double() ==
467-
3.141593);
502+
logValue.as_object()["MessageParams"]
503+
.as_object()["Field2"]
504+
.get_uint64() == std::numeric_limits<std::uint64_t>::max());
505+
CHECK(
506+
logValue.as_object()["MessageParams"]
507+
.as_object()["Field3"]
508+
.get_double() == 3.141593);
468509
CHECK(logValue.as_object()["Message"].is_string());
469510
CHECK(
470511
logValue.as_object()["Message"].get_string() ==
@@ -483,15 +524,23 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJsonLogFields")
483524
CHECK(ec == boost::system::errc::success);
484525

485526
CHECK(logValue.as_object()["MessageParams"].is_object());
486-
CHECK(logValue.as_object()["MessageParams"].as_object()["Field1"].is_number());
487-
CHECK(logValue.as_object()["MessageParams"].as_object()["Field1"].get_int64() == 1);
527+
CHECK(logValue.as_object()["MessageParams"]
528+
.as_object()["Field1"]
529+
.is_number());
530+
CHECK(
531+
logValue.as_object()["MessageParams"]
532+
.as_object()["Field1"]
533+
.get_int64() == 1);
488534
// UInt64 doesn't fit in Json::Value so it should be converted to a string
489535
// NOTE: We should expect it to be an int64 after we make the json library
490536
// support in64 and uint64
491-
CHECK(logValue.as_object()["MessageParams"].as_object()["Field2"].is_number());
537+
CHECK(logValue.as_object()["MessageParams"]
538+
.as_object()["Field2"]
539+
.is_number());
492540
CHECK(
493-
logValue.as_object()["MessageParams"].as_object()["Field2"].get_uint64() ==
494-
std::numeric_limits<std::uint64_t>::max());
541+
logValue.as_object()["MessageParams"]
542+
.as_object()["Field2"]
543+
.get_uint64() == std::numeric_limits<std::uint64_t>::max());
495544
CHECK(logValue.as_object()["Message"].is_string());
496545
CHECK(logValue.as_object()["Message"].get_string() == "Test");
497546
}
@@ -508,12 +557,20 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJournalAttributes")
508557
auto logValue = boost::json::parse(stream().str(), ec);
509558
CHECK(ec == boost::system::errc::success);
510559

511-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field1"].is_string());
560+
CHECK(logValue.as_object()["JournalParams"]
561+
.as_object()["Field1"]
562+
.is_string());
512563
CHECK(
513-
logValue.as_object()["JournalParams"].as_object()["Field1"].get_string() ==
514-
std::string{"Value1"});
515-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].is_number());
516-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].get_int64() == 2);
564+
logValue.as_object()["JournalParams"]
565+
.as_object()["Field1"]
566+
.get_string() == std::string{"Value1"});
567+
CHECK(logValue.as_object()["JournalParams"]
568+
.as_object()["Field2"]
569+
.is_number());
570+
CHECK(
571+
logValue.as_object()["JournalParams"]
572+
.as_object()["Field2"]
573+
.get_int64() == 2);
517574
}
518575

519576
TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJournalAttributesInheritable")
@@ -529,16 +586,27 @@ TEST_CASE_FIXTURE(JsonLogStreamFixture, "TestJournalAttributesInheritable")
529586
auto logValue = boost::json::parse(stream().str(), ec);
530587
CHECK(ec == boost::system::errc::success);
531588

532-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field1"].is_string());
589+
CHECK(logValue.as_object()["JournalParams"]
590+
.as_object()["Field1"]
591+
.is_string());
592+
CHECK(
593+
logValue.as_object()["JournalParams"]
594+
.as_object()["Field1"]
595+
.get_string() == std::string{"Value1"});
596+
CHECK(logValue.as_object()["JournalParams"]
597+
.as_object()["Field3"]
598+
.is_string());
533599
CHECK(
534-
logValue.as_object()["JournalParams"].as_object()["Field1"].get_string() ==
535-
std::string{"Value1"});
536-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field3"].is_string());
600+
logValue.as_object()["JournalParams"]
601+
.as_object()["Field3"]
602+
.get_string() == std::string{"Value3"});
603+
CHECK(logValue.as_object()["JournalParams"]
604+
.as_object()["Field2"]
605+
.is_number());
537606
CHECK(
538-
logValue.as_object()["JournalParams"].as_object()["Field3"].get_string() ==
539-
std::string{"Value3"});
540-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].is_number());
541-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].get_int64() == 2);
607+
logValue.as_object()["JournalParams"]
608+
.as_object()["Field2"]
609+
.get_int64() == 2);
542610
}
543611

544612
TEST_CASE_FIXTURE(
@@ -556,17 +624,28 @@ TEST_CASE_FIXTURE(
556624
auto logValue = boost::json::parse(stream().str(), ec);
557625
CHECK(ec == boost::system::errc::success);
558626

559-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field1"].is_string());
627+
CHECK(logValue.as_object()["JournalParams"]
628+
.as_object()["Field1"]
629+
.is_string());
560630
CHECK(
561-
logValue.as_object()["JournalParams"].as_object()["Field1"].get_string() ==
562-
std::string{"Value1"});
563-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field3"].is_string());
631+
logValue.as_object()["JournalParams"]
632+
.as_object()["Field1"]
633+
.get_string() == std::string{"Value1"});
634+
CHECK(logValue.as_object()["JournalParams"]
635+
.as_object()["Field3"]
636+
.is_string());
564637
CHECK(
565-
logValue.as_object()["JournalParams"].as_object()["Field3"].get_string() ==
566-
std::string{"Value3"});
638+
logValue.as_object()["JournalParams"]
639+
.as_object()["Field3"]
640+
.get_string() == std::string{"Value3"});
567641
// Field2 should be overwritten to 0
568-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].is_number());
569-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].get_int64() == 2);
642+
CHECK(logValue.as_object()["JournalParams"]
643+
.as_object()["Field2"]
644+
.is_number());
645+
CHECK(
646+
logValue.as_object()["JournalParams"]
647+
.as_object()["Field2"]
648+
.get_int64() == 2);
570649
}
571650

572651
TEST_CASE_FIXTURE(
@@ -587,12 +666,20 @@ TEST_CASE_FIXTURE(
587666
auto logValue = boost::json::parse(stream().str(), ec);
588667
CHECK(ec == boost::system::errc::success);
589668

590-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field1"].is_string());
669+
CHECK(logValue.as_object()["JournalParams"]
670+
.as_object()["Field1"]
671+
.is_string());
591672
CHECK(
592-
logValue.as_object()["JournalParams"].as_object()["Field1"].get_string() ==
593-
std::string{"Value1"});
594-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].is_number());
595-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].get_int64() == 2);
673+
logValue.as_object()["JournalParams"]
674+
.as_object()["Field1"]
675+
.get_string() == std::string{"Value1"});
676+
CHECK(logValue.as_object()["JournalParams"]
677+
.as_object()["Field2"]
678+
.is_number());
679+
CHECK(
680+
logValue.as_object()["JournalParams"]
681+
.as_object()["Field2"]
682+
.get_int64() == 2);
596683
}
597684

598685
TEST_CASE_FIXTURE(
@@ -613,10 +700,18 @@ TEST_CASE_FIXTURE(
613700
auto logValue = boost::json::parse(stream().str(), ec);
614701
CHECK(ec == boost::system::errc::success);
615702

616-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field1"].is_string());
703+
CHECK(logValue.as_object()["JournalParams"]
704+
.as_object()["Field1"]
705+
.is_string());
706+
CHECK(
707+
logValue.as_object()["JournalParams"]
708+
.as_object()["Field1"]
709+
.get_string() == std::string{"Value1"});
710+
CHECK(logValue.as_object()["JournalParams"]
711+
.as_object()["Field2"]
712+
.is_number());
617713
CHECK(
618-
logValue.as_object()["JournalParams"].as_object()["Field1"].get_string() ==
619-
std::string{"Value1"});
620-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].is_number());
621-
CHECK(logValue.as_object()["JournalParams"].as_object()["Field2"].get_int64() == 2);
714+
logValue.as_object()["JournalParams"]
715+
.as_object()["Field2"]
716+
.get_int64() == 2);
622717
}

0 commit comments

Comments
 (0)