Skip to content
11 changes: 5 additions & 6 deletions FppTestProject/FppTest/struct/NonPrimitiveTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ TEST_F(NonPrimitiveTest, ToString) {
NonPrimitive s(testString, testEnum, testArray, testArray, testStruct, testStruct, testU32Arr, testStructArr);
std::stringstream buf1, buf2;

buf1 << s;
Fw::StringTemplate<1024> str;
s.toString(str);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better for testing s.toString, but now it doesn't test the << method of s at all. Can we keep both tests here (the truncated and non-truncated versions)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test to explicitly verify both the truncated operator<< behavior and the non-truncated toString() output using the larger buffer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you apply the same change to PrimitiveTest? The two cases (PrimitiveTest, NonPrimitiveTest) should operate in the same way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've updated PrimitiveTest to follow the exact same two-case testing pattern, verifying both the truncated operator<< output and the full toString() output.

buf1 << str;

buf2 << "( "
<< "mString = " << testString << ", "
Expand All @@ -294,12 +296,9 @@ TEST_F(NonPrimitiveTest, ToString) {
<< "mAliasStruct = " << testStruct << ", "
<< "mU32Arr = [ " << testU32Arr[0] << ", " << testU32Arr[1] << ", " << testU32Arr[2] << " ], "
<< "mStructArr = [ " << testStructArr[0] << ", " << testStructArr[1] << ", " << testStructArr[2] << " ] "
Comment thread
karan9617 marked this conversation as resolved.
Outdated
<< " )";
<< ")";
Comment thread
karan9617 marked this conversation as resolved.
Outdated
Comment thread
bocchino marked this conversation as resolved.
Outdated

// Truncate string output
Fw::String s2(buf2.str().c_str());

ASSERT_STREQ(buf1.str().c_str(), s2.toChar());
ASSERT_EQ(buf1.str(), buf2.str());
}

} // namespace Struct
Expand Down
2 changes: 1 addition & 1 deletion FppTestProject/FppTest/struct/PrimitiveTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ REGISTER_TYPED_TEST_SUITE_P(PrimitiveTest,
ToString);

using PrimitiveTestImplementations = ::testing::Types<C_Primitive, SM_SMPrimitive>;
INSTANTIATE_TYPED_TEST_SUITE_P(FppTest, PrimitiveTest, PrimitiveTestImplementations);
INSTANTIATE_TYPED_TEST_SUITE_P(FppTest, PrimitiveTest, PrimitiveTestImplementations, );
Comment thread
karan9617 marked this conversation as resolved.
Outdated

} // namespace Struct

Expand Down
2 changes: 1 addition & 1 deletion FppTestProject/FppTest/struct/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// Instantiate string tests for structs
using StringTestImplementations =
::testing::Types<Fw::StringTemplate<80>, Fw::StringTemplate<50>, Fw::StringTemplate<60> >;
INSTANTIATE_TYPED_TEST_SUITE_P(Struct, StringTest, StringTestImplementations);
INSTANTIATE_TYPED_TEST_SUITE_P(Struct, StringTest, StringTestImplementations, );
Comment thread
bocchino marked this conversation as resolved.
Outdated

int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
Expand Down
6 changes: 3 additions & 3 deletions FppTestProject/FppTest/struct/struct.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ module FppTest {
}

type StructAliasString = string size 30
type StructAliasStringZero = string size 0
type StructAliasStringZero = string size 1
Comment thread
karan9617 marked this conversation as resolved.
Outdated

struct MultiString {
mStr_1: string
mStr_2: string
mStr50_1: string size 50
mStr50_2: string size 50
mStr0: string size 0
mStr0: string size 1
mStrArr_1: [3] string size 60
mStrArr_2: [3] string size 60
mStrArr0: [3] string size 0
mStrArr0: [3] string size 1
mStrAlias: StructAliasString
mStrAlias_2: [3] StructAliasString
mStrAlias0: StructAliasStringZero
Expand Down
Loading