diff --git a/FppTestProject/FppTest/array/ArrayToStringTest.cpp b/FppTestProject/FppTest/array/ArrayToStringTest.cpp index de09324ca12..2ce4feec9a8 100644 --- a/FppTestProject/FppTest/array/ArrayToStringTest.cpp +++ b/FppTestProject/FppTest/array/ArrayToStringTest.cpp @@ -44,20 +44,25 @@ TYPED_TEST_SUITE(ArrayToStringTest, ArrayTypes); // Test array toString() and ostream operator functions TYPED_TEST(ArrayToStringTest, ToString) { TypeParam a(this->testVals); - std::stringstream buf1, buf2; + std::stringstream actualStream; + std::stringstream expectedStream; - buf1 << a; + actualStream << a; - buf2 << "[ "; + // Construct the full expected string + expectedStream << "[ "; for (U32 i = 0; i < TypeParam::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expectedStream << ", "; } - buf2 << this->testVals[i]; + expectedStream << this->testVals[i]; } - buf2 << " ]"; + expectedStream << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + // Handle F Prime string truncation + Fw::String expected(expectedStream.str().c_str()); + + ASSERT_STREQ(actualStream.str().c_str(), expected.toChar()); } } // namespace Array diff --git a/FppTestProject/FppTest/array/FormatTest.cpp b/FppTestProject/FppTest/array/FormatTest.cpp index 7b6fd2d8c29..b4b0c5421ba 100644 --- a/FppTestProject/FppTest/array/FormatTest.cpp +++ b/FppTestProject/FppTest/array/FormatTest.cpp @@ -38,201 +38,202 @@ namespace Array { // Tests FPP format strings class FormatTest : public ::testing::Test { protected: - void SetUp() override { buf2 << "[ "; } + void SetUp() override { expected << "[ "; } - std::stringstream buf1, buf2; + std::stringstream actual; + std::stringstream expected; }; TEST_F(FormatTest, Bool) { bool testVals[FormatBool::SIZE] = {true, true, false}; FormatBool a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatBool::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << testVals[i] << " b"; + expected << "a " << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, U8) { U8 testVals[FormatU8::SIZE] = {0, 100, std::numeric_limits::max()}; FormatU8 a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatU8::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << static_cast(testVals[i]) << " b"; + expected << "a " << static_cast(testVals[i]) << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, U16Dec) { U16 testVals[FormatU16Dec::SIZE] = {0, 100, std::numeric_limits::max()}; FormatU16Dec a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatU16Dec::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::dec << testVals[i] << " b"; + expected << "a " << std::dec << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, U32Oct) { U32 testVals[FormatU32Oct::SIZE] = {0, 100, std::numeric_limits::max()}; FormatU32Oct a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatU32Oct::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::oct << testVals[i] << " b"; + expected << "a " << std::oct << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, U64Hex) { U64 testVals[FormatU64Hex::SIZE] = {0, 100, std::numeric_limits::max()}; FormatU64Hex a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatU64Hex::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::hex << testVals[i] << " b"; + expected << "a " << std::hex << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, I8) { I8 testVals[FormatI8::SIZE] = {std::numeric_limits::min(), 0, std::numeric_limits::max()}; FormatI8 a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatI8::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << static_cast(testVals[i]) << " b"; + expected << "a " << static_cast(testVals[i]) << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, I16Dec) { I16 testVals[FormatI16Dec::SIZE] = {std::numeric_limits::min(), 0, std::numeric_limits::max()}; FormatI16Dec a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatI16Dec::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::dec << testVals[i] << " b"; + expected << "a " << std::dec << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, I32Oct) { I32 testVals[FormatI32Oct::SIZE] = {std::numeric_limits::min(), 0, std::numeric_limits::max()}; FormatI32Oct a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatI32Oct::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::oct << testVals[i] << " b"; + expected << "a " << std::oct << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, I64Hex) { I64 testVals[FormatI64Hex::SIZE] = {std::numeric_limits::min(), 0, std::numeric_limits::max()}; FormatI64Hex a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatI64Hex::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::hex << testVals[i] << " b"; + expected << "a " << std::hex << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, F32E) { F32 testVals[FormatF32e::SIZE] = {std::numeric_limits::min(), 0.0, std::numeric_limits::max()}; FormatF32e a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatF32e::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::setprecision(1) << std::scientific << testVals[i] << " b"; + expected << "a " << std::setprecision(1) << std::scientific << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, F32F) { F32 testVals[FormatF32f::SIZE] = {std::numeric_limits::min(), 0.0, std::numeric_limits::max()}; FormatF32f a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatF32f::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::setprecision(2) << std::fixed << testVals[i] << " b"; + expected << "a " << std::setprecision(2) << std::fixed << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, F64G) { F64 testVals[FormatF64g::SIZE] = {std::numeric_limits::min(), 0.0, std::numeric_limits::max()}; FormatF64g a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatF64g::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << std::setprecision(3) << testVals[i] << " b"; + expected << "a " << std::setprecision(3) << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } TEST_F(FormatTest, String) { @@ -245,16 +246,23 @@ TEST_F(FormatTest, String) { FormatString a(testVals); - buf1 << a; + actual << a; + + // Construct the full expected string + std::stringstream expectedStream; + expectedStream << "[ "; for (U32 i = 0; i < FormatString::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expectedStream << ", "; } - buf2 << "% " << testVals[i].toChar(); + expectedStream << "% " << testVals[i]; } - buf2 << " ]"; + expectedStream << " ]"; + + // Handle F Prime string truncation + Fw::String expectedString(expectedStream.str().c_str()); - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expectedString.toChar()); } TEST_F(FormatTest, Char) { @@ -262,16 +270,16 @@ TEST_F(FormatTest, Char) { FppTest::Utils::getNonzeroU8()}; FormatChar a(testVals); - buf1 << a; + actual << a; for (U32 i = 0; i < FormatChar::SIZE; i++) { if (i > 0) { - buf2 << ", "; + expected << ", "; } - buf2 << "a " << testVals[i] << " b"; + expected << "a " << testVals[i] << " b"; } - buf2 << " ]"; + expected << " ]"; - ASSERT_STREQ(buf1.str().c_str(), buf2.str().c_str()); + ASSERT_STREQ(actual.str().c_str(), expected.str().c_str()); } } // namespace Array diff --git a/FppTestProject/FppTest/component/tests/EventTests.cpp b/FppTestProject/FppTest/component/tests/EventTests.cpp index f186d27b591..2c8ae095a3b 100644 --- a/FppTestProject/FppTest/component/tests/EventTests.cpp +++ b/FppTestProject/FppTest/component/tests/EventTests.cpp @@ -61,7 +61,7 @@ void Tester ::testEvent(FwIndexType portNum, FppTest::Types::LogStringParams& da ASSERT_EVENTS_SIZE(1); ASSERT_EVENTS_EventString_SIZE(1); - Fw::StringTemplate<80> arg1(data.args.val1); + Fw::String arg1(data.args.val1); Fw::StringTemplate<100> arg2(data.args.val2); ASSERT_EVENTS_EventString(static_cast(portNum), arg1.toChar(), arg2.toChar()); diff --git a/FppTestProject/FppTest/state_machine/internal/state/include/BasicString.fppi b/FppTestProject/FppTest/state_machine/internal/state/include/BasicString.fppi index df2b31dd056..24a7bd055d2 100644 --- a/FppTestProject/FppTest/state_machine/internal/state/include/BasicString.fppi +++ b/FppTestProject/FppTest/state_machine/internal/state/include/BasicString.fppi @@ -1,8 +1,8 @@ -constant basicStringSize = 80 - @ A basic state machine with string actions state machine BasicString { + constant stringSize = 80 + @ Action a action a @@ -10,7 +10,10 @@ state machine BasicString { action b: string @ Signal s - signal s: string + signal s: string size 200 + + @ Signal s1 + signal s1: string size 100 initial enter S diff --git a/FppTestProject/FppTest/state_machine/internal_instance/state/BasicStringTester.cpp b/FppTestProject/FppTest/state_machine/internal_instance/state/BasicStringTester.cpp index 225b63e8205..f5f1da3b3c6 100644 --- a/FppTestProject/FppTest/state_machine/internal_instance/state/BasicStringTester.cpp +++ b/FppTestProject/FppTest/state_machine/internal_instance/state/BasicStringTester.cpp @@ -51,7 +51,7 @@ void BasicStringTester::test() { ASSERT_EQ(this->smStateBasicString_getState(), SmState_BasicString::State::S); ASSERT_EQ(this->m_smStateBasicString_action_a_history.getSize(), 0); Fw::String value; - SmHarness::Pick::string(value, SmState::basicStringSize); + SmHarness::Pick::string(value, SmState::BasicString_stringSize); this->smStateBasicString_sendSignal_s(value); const auto status = this->doDispatch(); ASSERT_EQ(status, MSG_DISPATCH_OK); diff --git a/FppTestProject/FppTest/struct/NonPrimitiveTest.cpp b/FppTestProject/FppTest/struct/NonPrimitiveTest.cpp index 4423afb8790..1690199bf9e 100644 --- a/FppTestProject/FppTest/struct/NonPrimitiveTest.cpp +++ b/FppTestProject/FppTest/struct/NonPrimitiveTest.cpp @@ -94,7 +94,7 @@ TEST_F(NonPrimitiveTest, Default) { Primitive defaultStruct2(true, 0, 0, 1.16); // Constants - ASSERT_EQ(NonPrimitive::SERIALIZED_SIZE, Fw::StringBase::STATIC_SERIALIZED_SIZE(80) + StructEnum::SERIALIZED_SIZE + + ASSERT_EQ(NonPrimitive::SERIALIZED_SIZE, Fw::String::SERIALIZED_SIZE + StructEnum::SERIALIZED_SIZE + StructArray::SERIALIZED_SIZE + StructArrAlias::SERIALIZED_SIZE + Primitive::SERIALIZED_SIZE + StructSAlias::SERIALIZED_SIZE + (3 * sizeof(U32)) + (3 * Primitive::SERIALIZED_SIZE)); @@ -245,8 +245,8 @@ TEST_F(NonPrimitiveTest, Serialization) { NonPrimitive sCopy; U32 stringSerializedSize = static_cast(testString.length() + sizeof(FwBuffSizeType)); - U32 serializedSize = static_cast(NonPrimitive::SERIALIZED_SIZE - Fw::StringBase::STATIC_SERIALIZED_SIZE(80) + - stringSerializedSize); + U32 serializedSize = + static_cast(NonPrimitive::SERIALIZED_SIZE - Fw::String::SERIALIZED_SIZE + stringSerializedSize); Fw::SerializeStatus status; // Test successful serialization diff --git a/Ref/DpDemo/DpDemo.fpp b/Ref/DpDemo/DpDemo.fpp index 15a80e3d6e3..09ce3488b6d 100644 --- a/Ref/DpDemo/DpDemo.fpp +++ b/Ref/DpDemo/DpDemo.fpp @@ -2,6 +2,8 @@ module Ref { @ DP Demo active component DpDemo { + constant stringSize = 80 + enum ColorEnum { RED GREEN @@ -13,7 +15,7 @@ module Ref { ASYNC } - type StringAlias = string + type StringAlias = string size stringSize type BoolAlias = bool type I32Alias = I32 type F64Alias = F64 @@ -25,7 +27,7 @@ module Ref { array U32Array = [5] U32 @ Array of strings - array StringArray = [2] string + array StringArray = [2] string size stringSize @ Array of array of strings array ArrayOfStringArray = [3] StringArray @@ -43,14 +45,14 @@ module Ref { } struct StructWithStringMembers { - stringMember: string, + stringMember: string size stringSize, stringArrayMember: StringArray } struct StructWithEverything { integerMember: I32Alias, floatMember: F32, - stringMember: string, + stringMember: string size stringSize, booleanMember: bool, enumMember: ColorEnum, arrayMemberU32: [2] U32Array, @@ -188,7 +190,7 @@ module Ref { product record EnumArrayRecord: EnumArray id 9 @ Data product record - string array record - product record StringArrayRecord: string array id 10 + product record StringArrayRecord: string size stringSize array id 10 @ Data product record - array record (structs) product record StructArrayRecord: StructWithStringMembers array id 11 diff --git a/Svc/FrameAccumulator/FrameDetector/CcsdsTcFrameDetector.hpp b/Svc/FrameAccumulator/FrameDetector/CcsdsTcFrameDetector.hpp index dd8e68ca01d..7d9bbb898b3 100644 --- a/Svc/FrameAccumulator/FrameDetector/CcsdsTcFrameDetector.hpp +++ b/Svc/FrameAccumulator/FrameDetector/CcsdsTcFrameDetector.hpp @@ -42,8 +42,7 @@ class CcsdsTcFrameDetector : public FrameDetector { protected: //! \brief expected flags and spacecraft ID token for a valid CCSDS TC frame - const U16 m_expectedFlagsAndScIdToken = - 0x1 << Ccsds::TCSubfields::BypassFlagOffset | (ComCfg::FppConstant_SpacecraftId::SpacecraftId); + const U16 m_expectedFlagsAndScIdToken = (0x1 << Ccsds::TCSubfields::BypassFlagOffset) | (ComCfg::SpacecraftId); }; // class CcsdsTcFrameDetector } // namespace FrameDetectors diff --git a/Svc/FrameAccumulator/test/ut/detectors/CcsdsTcFrameDetectorTestMain.cpp b/Svc/FrameAccumulator/test/ut/detectors/CcsdsTcFrameDetectorTestMain.cpp index 26ca8fcc74c..6b91a924e6f 100644 --- a/Svc/FrameAccumulator/test/ut/detectors/CcsdsTcFrameDetectorTestMain.cpp +++ b/Svc/FrameAccumulator/test/ut/detectors/CcsdsTcFrameDetectorTestMain.cpp @@ -15,8 +15,7 @@ using namespace Svc::Ccsds; constexpr U32 CIRCULAR_BUFFER_TEST_SIZE = 2048; -constexpr U16 EXPECTED_START_TOKEN = - 0x1 << TCSubfields::BypassFlagOffset | (ComCfg::FppConstant_SpacecraftId::SpacecraftId); +constexpr U16 EXPECTED_START_TOKEN = (0x1 << TCSubfields::BypassFlagOffset) | (ComCfg::SpacecraftId); // Test fixture to set up the detector under test and circular buffer class CcsdsFrameDetectorTest : public ::testing::Test { diff --git a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTestMain.cpp b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTestMain.cpp index a1d76c6fbe0..970bacfeaa9 100644 --- a/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTestMain.cpp +++ b/Svc/PassiveRateGroup/test/ut/PassiveRateGroupTestMain.cpp @@ -33,7 +33,7 @@ void connectPorts(Svc::PassiveRateGroup& impl, Svc::PassiveRateGroupTester& test TEST(PassiveRateGroupTest, NominalSchedule) { for (FwEnumStoreType inst = 0; inst < 3; inst++) { - U32 contexts[FppConstant_PassiveRateGroupOutputPorts::PassiveRateGroupOutputPorts] = {1, 2, 3, 4, 5}; + U32 contexts[PassiveRateGroupOutputPorts] = {1, 2, 3, 4, 5}; Svc::PassiveRateGroup impl("PassiveRateGroup"); impl.configure(contexts, FW_NUM_ARRAY_ELEMENTS(contexts)); diff --git a/requirements.txt b/requirements.txt index ce473ce1f43..f5446ea75ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ Flask-Compress==1.15 Flask-RESTful==0.3.10 fprime-fpl-layout==1.0.3 fprime-fpl-write-pic==1.0.3 -fprime-fpp==3.1.1a3 +fprime-fpp==3.1.1a4 fprime-gds==4.1.1a4 fprime-tools==4.1.0 fprime-visual==1.0.2