@@ -58,7 +58,7 @@ static const std::uint8_t FUEL_FIGURES_COUNT = 3;
58
58
static const std::uint8_t ACCELERATION_COUNT = 3 ;
59
59
60
60
static const std::uint64_t expectedHeaderSize = 8 ;
61
- static const std::uint64_t expectedCarSize = 207 ;
61
+ static const std::uint64_t expectedCarEncodedLength = 207 ;
62
62
63
63
static const std::uint16_t fuel1Speed = 30 ;
64
64
static const float fuel1Mpg = 35 .9f ;
@@ -443,6 +443,7 @@ TEST_F(CodeGenTest, shouldBeAbleToEncodeCarCorrectly)
443
443
ACTIVATION_CODE_LENGTH,
444
444
COLOR_LENGTH
445
445
);
446
+
446
447
EXPECT_EQ (sz, predictedCarSz);
447
448
EXPECT_EQ (Car::isConstLength (), false );
448
449
EXPECT_EQ (Car::PerformanceFigures::Acceleration::isConstLength (), true );
@@ -454,14 +455,14 @@ TEST_F(CodeGenTest, shouldBeAbleToEncodeHeaderPlusCarCorrectly)
454
455
const char *bp = buffer;
455
456
456
457
std::uint64_t hdrSz = encodeHdr (buffer, 0 , sizeof (buffer));
457
- std::uint64_t carSz = encodeCar (buffer, m_hdr.encodedLength (), sizeof (buffer) - m_hdr.encodedLength ());
458
+ std::uint64_t carEncodedLength = encodeCar (buffer, m_hdr.encodedLength (), sizeof (buffer) - m_hdr.encodedLength ());
458
459
459
460
EXPECT_EQ (hdrSz, expectedHeaderSize);
460
- EXPECT_EQ (carSz, expectedCarSize );
461
+ EXPECT_EQ (carEncodedLength, expectedCarEncodedLength );
461
462
462
463
EXPECT_EQ (*((std::uint16_t *)bp), Car::sbeBlockLength ());
463
464
const size_t activationCodePosition =
464
- (hdrSz + carSz ) - (ACTIVATION_CODE_LENGTH + sizeof (std::uint32_t ) + COLOR_LENGTH);
465
+ (hdrSz + carEncodedLength ) - (ACTIVATION_CODE_LENGTH + sizeof (std::uint32_t ) + COLOR_LENGTH);
465
466
const size_t activationCodeLengthPosition = activationCodePosition - sizeof (std::uint16_t );
466
467
EXPECT_EQ (*(std::uint16_t *)(bp + activationCodeLengthPosition), ACTIVATION_CODE_LENGTH);
467
468
EXPECT_EQ (std::string (bp + activationCodePosition, ACTIVATION_CODE_LENGTH), ACTIVATION_CODE);
@@ -472,10 +473,10 @@ TEST_F(CodeGenTest, shouldBeAbleToEncodeAndDecodeHeaderPlusCarCorrectly)
472
473
char buffer[BUFFER_LEN];
473
474
474
475
std::uint64_t hdrSz = encodeHdr (buffer, 0 , sizeof (buffer));
475
- std::uint64_t carSz = encodeCar (buffer, m_hdr.encodedLength (), sizeof (buffer) - m_hdr.encodedLength ());
476
+ std::uint64_t carEncodedLength = encodeCar (buffer, m_hdr.encodedLength (), sizeof (buffer) - m_hdr.encodedLength ());
476
477
477
478
EXPECT_EQ (hdrSz, expectedHeaderSize);
478
- EXPECT_EQ (carSz, expectedCarSize );
479
+ EXPECT_EQ (carEncodedLength, expectedCarEncodedLength );
479
480
480
481
m_hdrDecoder.wrap (buffer, 0 , 0 , hdrSz);
481
482
@@ -485,9 +486,9 @@ TEST_F(CodeGenTest, shouldBeAbleToEncodeAndDecodeHeaderPlusCarCorrectly)
485
486
EXPECT_EQ (m_hdrDecoder.version (), Car::sbeSchemaVersion ());
486
487
EXPECT_EQ (m_hdrDecoder.encodedLength (), expectedHeaderSize);
487
488
488
- m_carDecoder.wrapForDecode (buffer, m_hdrDecoder.encodedLength (), Car::sbeBlockLength (), Car::sbeSchemaVersion (), hdrSz + carSz );
489
+ m_carDecoder.wrapForDecode (buffer, m_hdrDecoder.encodedLength (), Car::sbeBlockLength (), Car::sbeSchemaVersion (), hdrSz + carEncodedLength );
489
490
490
- EXPECT_EQ (m_carDecoder.decodeLength (), expectedCarSize );
491
+ EXPECT_EQ (m_carDecoder.decodeLength (), expectedCarEncodedLength );
491
492
492
493
EXPECT_EQ (m_carDecoder.serialNumber (), SERIAL_NUMBER);
493
494
EXPECT_EQ (m_carDecoder.modelYear (), MODEL_YEAR);
@@ -599,8 +600,8 @@ TEST_F(CodeGenTest, shouldBeAbleToEncodeAndDecodeHeaderPlusCarCorrectly)
599
600
EXPECT_EQ (m_carDecoder.colorLength (), COLOR_LENGTH);
600
601
EXPECT_EQ (std::string (m_carDecoder.color (), COLOR_LENGTH), COLOR);
601
602
602
- EXPECT_EQ (m_carDecoder.encodedLength (), expectedCarSize );
603
- EXPECT_EQ (m_carDecoder.decodeLength (), expectedCarSize );
603
+ EXPECT_EQ (m_carDecoder.encodedLength (), expectedCarEncodedLength );
604
+ EXPECT_EQ (m_carDecoder.decodeLength (), expectedCarEncodedLength );
604
605
}
605
606
606
607
struct CallbacksForEach
@@ -638,10 +639,10 @@ TEST_F(CodeGenTest, shouldBeAbleUseOnStackCodecsAndGroupForEach)
638
639
Car car (buffer + hdr.encodedLength (), sizeof (buffer) - hdr.encodedLength ());
639
640
640
641
std::uint64_t hdrSz = encodeHdr (hdr);
641
- std::uint64_t carSz = encodeCar (car);
642
+ std::uint64_t carEncodedLength = encodeCar (car);
642
643
643
644
EXPECT_EQ (hdrSz, expectedHeaderSize);
644
- EXPECT_EQ (carSz, expectedCarSize );
645
+ EXPECT_EQ (carEncodedLength, expectedCarEncodedLength );
645
646
646
647
const MessageHeader hdrDecoder (buffer, hdrSz, 0 );
647
648
@@ -651,7 +652,7 @@ TEST_F(CodeGenTest, shouldBeAbleUseOnStackCodecsAndGroupForEach)
651
652
EXPECT_EQ (hdrDecoder.version (), Car::sbeSchemaVersion ());
652
653
EXPECT_EQ (hdrDecoder.encodedLength (), expectedHeaderSize);
653
654
654
- Car carDecoder (buffer + hdrDecoder.encodedLength (), carSz , hdrDecoder.blockLength (), hdrDecoder.version ());
655
+ Car carDecoder (buffer + hdrDecoder.encodedLength (), carEncodedLength , hdrDecoder.blockLength (), hdrDecoder.version ());
655
656
CallbacksForEach cbs;
656
657
657
658
Car::FuelFigures &fuelFigures = carDecoder.fuelFigures ();
@@ -707,7 +708,7 @@ TEST_F(CodeGenTest, shouldBeAbleUseOnStackCodecsAndGroupForEach)
707
708
EXPECT_EQ (carDecoder.getColor (tmp, sizeof (tmp)), COLOR_LENGTH);
708
709
EXPECT_EQ (std::string (tmp, COLOR_LENGTH), COLOR);
709
710
710
- EXPECT_EQ (carDecoder.encodedLength (), expectedCarSize );
711
+ EXPECT_EQ (carDecoder.encodedLength (), expectedCarEncodedLength );
711
712
}
712
713
713
714
static const std::size_t offsetVehicleCode = 32 ;
@@ -762,29 +763,36 @@ TEST_F(CodeGenTest, shouldBeAbleToUseStdStringMethodsForEncode)
762
763
.putActivationCode (activationCode)
763
764
.putColor (color);
764
765
765
- EXPECT_EQ (car.encodedLength (), expectedCarSize );
766
+ EXPECT_EQ (car.encodedLength (), expectedCarEncodedLength );
766
767
767
768
EXPECT_EQ (std::string (buffer + baseOffset + offsetVehicleCode, VEHICLE_CODE_LENGTH), vehicleCode);
768
769
769
- EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetUsageDesc1Length), FUEL_FIGURES_1_USAGE_DESCRIPTION_LENGTH);
770
+ EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetUsageDesc1Length),
771
+ static_cast <std::uint16_t >(FUEL_FIGURES_1_USAGE_DESCRIPTION_LENGTH));
770
772
EXPECT_EQ (std::string (buffer + baseOffset + offsetUsageDesc1Data, FUEL_FIGURES_1_USAGE_DESCRIPTION_LENGTH), usageDesc1);
771
773
772
- EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetUsageDesc2Length), FUEL_FIGURES_2_USAGE_DESCRIPTION_LENGTH);
774
+ EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetUsageDesc2Length),
775
+ static_cast <std::uint16_t >(FUEL_FIGURES_2_USAGE_DESCRIPTION_LENGTH));
773
776
EXPECT_EQ (std::string (buffer + baseOffset + offsetUsageDesc2Data, FUEL_FIGURES_2_USAGE_DESCRIPTION_LENGTH), usageDesc2);
774
777
775
- EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetUsageDesc3Length), FUEL_FIGURES_3_USAGE_DESCRIPTION_LENGTH);
778
+ EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetUsageDesc3Length),
779
+ static_cast <std::uint16_t >(FUEL_FIGURES_3_USAGE_DESCRIPTION_LENGTH));
776
780
EXPECT_EQ (std::string (buffer + baseOffset + offsetUsageDesc3Data, FUEL_FIGURES_3_USAGE_DESCRIPTION_LENGTH), usageDesc3);
777
781
778
- EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetManufacturerLength), MANUFACTURER_LENGTH);
782
+ EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetManufacturerLength),
783
+ static_cast <std::uint16_t >(MANUFACTURER_LENGTH));
779
784
EXPECT_EQ (std::string (buffer + baseOffset + offsetManufacturerData, MANUFACTURER_LENGTH), manufacturer);
780
785
781
- EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetModelLength), MODEL_LENGTH);
786
+ EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetModelLength),
787
+ static_cast <std::uint16_t >(MODEL_LENGTH));
782
788
EXPECT_EQ (std::string (buffer + baseOffset + offsetModelData, MODEL_LENGTH), model);
783
789
784
- EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetActivationCodeLength), ACTIVATION_CODE_LENGTH);
790
+ EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetActivationCodeLength),
791
+ static_cast <std::uint16_t >(ACTIVATION_CODE_LENGTH));
785
792
EXPECT_EQ (std::string (buffer + baseOffset + offsetActivationCodeData, ACTIVATION_CODE_LENGTH), activationCode);
786
793
787
- EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetColorLength), COLOR_LENGTH);
794
+ EXPECT_EQ (*(std::uint16_t *)(buffer + baseOffset + offsetColorLength),
795
+ static_cast <std::uint16_t >(COLOR_LENGTH));
788
796
EXPECT_EQ (std::string (buffer + baseOffset + offsetColorData, COLOR_LENGTH), color);
789
797
}
790
798
@@ -793,11 +801,11 @@ TEST_F(CodeGenTest, shouldBeAbleToUseStdStringMethodsForDecode)
793
801
char buffer[2048 ];
794
802
Car carEncoder (buffer, sizeof (buffer));
795
803
796
- std::uint64_t carSz = encodeCar (carEncoder);
804
+ std::uint64_t carEncodedLength = encodeCar (carEncoder);
797
805
798
- EXPECT_EQ (carSz, expectedCarSize );
806
+ EXPECT_EQ (carEncodedLength, expectedCarEncodedLength );
799
807
800
- Car carDecoder (buffer, carSz , Car::sbeBlockLength (), Car::sbeSchemaVersion ());
808
+ Car carDecoder (buffer, carEncodedLength , Car::sbeBlockLength (), Car::sbeSchemaVersion ());
801
809
802
810
std::string vehicleCode (VEHICLE_CODE, Car::vehicleCodeLength ());
803
811
std::string usageDesc1 (FUEL_FIGURES_1_USAGE_DESCRIPTION, FUEL_FIGURES_1_USAGE_DESCRIPTION_LENGTH);
@@ -837,7 +845,7 @@ TEST_F(CodeGenTest, shouldBeAbleToUseStdStringMethodsForDecode)
837
845
EXPECT_EQ (carDecoder.getActivationCodeAsString (), activationCode);
838
846
EXPECT_EQ (carDecoder.getColorAsString (), color);
839
847
840
- EXPECT_EQ (carDecoder.encodedLength (), expectedCarSize );
848
+ EXPECT_EQ (carDecoder.encodedLength (), expectedCarEncodedLength );
841
849
}
842
850
843
851
TEST_F (CodeGenTest, shouldPrintFullDecodedFlyweightRegardlessOfReadPosition)
@@ -861,11 +869,11 @@ TEST_F(CodeGenTest, shouldPrintFullDecodedFlyweightRegardlessOfReadPosition)
861
869
memset (buffer, 0 , 2048 );
862
870
Car carEncoder (buffer, sizeof (buffer));
863
871
864
- std::uint64_t carSz = encodeCar (carEncoder);
872
+ std::uint64_t carEncodedLength = encodeCar (carEncoder);
865
873
866
- EXPECT_EQ (carSz, expectedCarSize );
874
+ EXPECT_EQ (carEncodedLength, expectedCarEncodedLength );
867
875
868
- Car carDecoder (buffer, carSz , Car::sbeBlockLength (), Car::sbeSchemaVersion ());
876
+ Car carDecoder (buffer, carEncodedLength , Car::sbeBlockLength (), Car::sbeSchemaVersion ());
869
877
870
878
std::string vehicleCode (VEHICLE_CODE, Car::vehicleCodeLength ());
871
879
std::string usageDesc1 (FUEL_FIGURES_1_USAGE_DESCRIPTION, FUEL_FIGURES_1_USAGE_DESCRIPTION_LENGTH);
@@ -916,5 +924,5 @@ TEST_F(CodeGenTest, shouldPrintFullDecodedFlyweightRegardlessOfReadPosition)
916
924
917
925
expectDisplayString (expectedDisplayString, carDecoder);
918
926
919
- EXPECT_EQ (carDecoder.encodedLength (), expectedCarSize );
927
+ EXPECT_EQ (carDecoder.encodedLength (), expectedCarEncodedLength );
920
928
}
0 commit comments