@@ -2186,6 +2186,88 @@ TEST(BuiltinDataSerializationTests, interoperability_with_intercomdds)
2186
2186
}
2187
2187
}
2188
2188
2189
+ /* !
2190
+ * This test checks that Fast DDS can properly serialize ResourceLimitsQos in DATA(w) when it has more fields than
2191
+ * max_samples, max_instances and max_samples_per_instance. It also checks that those fields are not serialized
2192
+ * into the allocated_samples and extra samples fields.
2193
+ */
2194
+ TEST (BuiltinDataSerializationTests, interoperability_with_other_vendor_writer_resource_limits)
2195
+ {
2196
+ const VendorId_t other_vendor_id = { 0 , 1 };
2197
+ // DATA(w)
2198
+ {
2199
+ octet data_w_buffer[] =
2200
+ {
2201
+ // Encapsulation
2202
+ 0x00 , 0x03 , 0x00 , 0x00 ,
2203
+ // Resource limits
2204
+ 0x41 , 0x00 , 0x14 , 0x00 ,
2205
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x04 , 0x00 , 0x00 , 0x00 ,
2206
+ 0x05 , 0x00 , 0x00 , 0x00 ,
2207
+ // Sentinel
2208
+ 0x01 , 0x00 , 0x00 , 0x00
2209
+ };
2210
+
2211
+ CDRMessage_t msg (0 );
2212
+ msg.init (data_w_buffer, static_cast <uint32_t >(sizeof (data_w_buffer)));
2213
+ msg.length = msg.max_size ;
2214
+
2215
+ WriterProxyData wpd (max_unicast_locators, max_multicast_locators);
2216
+ EXPECT_NO_THROW (EXPECT_TRUE (wpd.read_from_cdr_message (&msg, other_vendor_id)));
2217
+
2218
+ ASSERT_TRUE (wpd.resource_limits );
2219
+ ASSERT_EQ (wpd.resource_limits ->max_samples , 1 );
2220
+ ASSERT_EQ (wpd.resource_limits ->max_instances , 2 );
2221
+ ASSERT_EQ (wpd.resource_limits ->max_samples_per_instance , 3 );
2222
+ // Allocated samples and extra samples should have default values as they should not be read because
2223
+ // they come from another vendor
2224
+ dds::ResourceLimitsQosPolicy default_values {};
2225
+ ASSERT_EQ (wpd.resource_limits ->allocated_samples , default_values.allocated_samples );
2226
+ ASSERT_EQ (wpd.resource_limits ->extra_samples , default_values.extra_samples );
2227
+ }
2228
+ }
2229
+
2230
+ /* !
2231
+ * This test checks that Fast DDS can properly serialize ResourceLimitsQos in DATA(r) when it has more fields than
2232
+ * max_samples, max_instances and max_samples_per_instance. It also checks that those fields are not serialized
2233
+ * into the allocated_samples and extra samples fields.
2234
+ */
2235
+ TEST (BuiltinDataSerializationTests, interoperability_with_other_vendor_reader_resource_limits)
2236
+ {
2237
+ const VendorId_t other_vendor_id = { 0 , 1 };
2238
+ // DATA(r)
2239
+ {
2240
+ uint8_t data_r_buffer[] =
2241
+ {
2242
+ // Encapsulation
2243
+ 0x00 , 0x03 , 0x00 , 0x00 ,
2244
+ // Resource limits
2245
+ 0x41 , 0x00 , 0x14 , 0x00 ,
2246
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x04 , 0x00 , 0x00 , 0x00 ,
2247
+ 0x05 , 0x00 , 0x00 , 0x00 ,
2248
+ // Sentinel
2249
+ 0x01 , 0x00 , 0x00 , 0x00
2250
+ };
2251
+
2252
+ CDRMessage_t msg (0 );
2253
+ msg.init (data_r_buffer, static_cast <uint32_t >(sizeof (data_r_buffer)));
2254
+ msg.length = msg.max_size ;
2255
+
2256
+ ReaderProxyData rpd (max_unicast_locators, max_multicast_locators);
2257
+ EXPECT_NO_THROW (EXPECT_TRUE (rpd.read_from_cdr_message (&msg, other_vendor_id)));
2258
+
2259
+ ASSERT_TRUE (rpd.resource_limits );
2260
+ ASSERT_EQ (rpd.resource_limits ->max_samples , 1 );
2261
+ ASSERT_EQ (rpd.resource_limits ->max_instances , 2 );
2262
+ ASSERT_EQ (rpd.resource_limits ->max_samples_per_instance , 3 );
2263
+ // Allocated samples and extra samples should have default values as they should not be read because
2264
+ // they come from another vendor
2265
+ dds::ResourceLimitsQosPolicy default_values {};
2266
+ ASSERT_EQ (rpd.resource_limits ->allocated_samples , default_values.allocated_samples );
2267
+ ASSERT_EQ (rpd.resource_limits ->extra_samples , default_values.extra_samples );
2268
+ }
2269
+ }
2270
+
2189
2271
/* !
2190
2272
* This is a regression test for redmine issue #21537
2191
2273
*
@@ -2654,6 +2736,41 @@ TEST(BuiltinDataSerializationTests, optional_qos_extensions_reader)
2654
2736
ASSERT_EQ (rpd.reader_resource_limits ->max_samples_per_read , 16 );
2655
2737
}
2656
2738
2739
+ /* !
2740
+ * This test checks that a correct ReaderProxyData is obtained when sending only max_samples, max_instances
2741
+ * and max_samples_per_instance in the ResourceLimits QoS policy
2742
+ */
2743
+ TEST (BuiltinDataSerializationTests, optional_qos_extensions_reader_resource_limits)
2744
+ {
2745
+ // DATA(r)
2746
+ uint8_t data_r_buffer[] =
2747
+ {
2748
+ // Encapsulation
2749
+ 0x00 , 0x03 , 0x00 , 0x00 ,
2750
+ // Resource limits (without allocated samples nor extra samples)
2751
+ 0x41 , 0x00 , 0x0c , 0x00 ,
2752
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 ,
2753
+ // Sentinel
2754
+ 0x01 , 0x00 , 0x00 , 0x00
2755
+ };
2756
+
2757
+ CDRMessage_t msg (0 );
2758
+ msg.init (data_r_buffer, static_cast <uint32_t >(sizeof (data_r_buffer)));
2759
+ msg.length = msg.max_size ;
2760
+
2761
+ ReaderProxyData rpd (max_unicast_locators, max_multicast_locators);
2762
+ EXPECT_NO_THROW (EXPECT_TRUE (rpd.read_from_cdr_message (&msg, c_VendorId_eProsima)));
2763
+
2764
+ ASSERT_TRUE (rpd.resource_limits );
2765
+ ASSERT_EQ (rpd.resource_limits ->max_samples , 1 );
2766
+ ASSERT_EQ (rpd.resource_limits ->max_instances , 2 );
2767
+ ASSERT_EQ (rpd.resource_limits ->max_samples_per_instance , 3 );
2768
+ // Allocated samples and extra samples should have default values as they are not present in the data
2769
+ dds::ResourceLimitsQosPolicy default_values {};
2770
+ ASSERT_EQ (rpd.resource_limits ->allocated_samples , default_values.allocated_samples );
2771
+ ASSERT_EQ (rpd.resource_limits ->extra_samples , default_values.extra_samples );
2772
+ }
2773
+
2657
2774
/* !
2658
2775
* This test checks that a correct WriterProxyData is obtained
2659
2776
* from eProsima's optional qos extensions in PublicationBuiltinTopicData
@@ -2773,6 +2890,41 @@ TEST(BuiltinDataSerializationTests, optional_qos_extensions_writer)
2773
2890
ASSERT_EQ (wpd.writer_resource_limits ->reader_filters_allocation .increment , 6u );
2774
2891
}
2775
2892
2893
+ /* !
2894
+ * This test checks that a correct WriterProxyData is obtained when sending only max_samples, max_instances
2895
+ * and max_samples_per_instance in the ResourceLimits QoS policy
2896
+ */
2897
+ TEST (BuiltinDataSerializationTests, optional_qos_extensions_writer_resource_limits)
2898
+ {
2899
+ // DATA(w)
2900
+ octet data_w_buffer[] =
2901
+ {
2902
+ // Encapsulation
2903
+ 0x00 , 0x03 , 0x00 , 0x00 ,
2904
+ // Resource limits (without allocated samples nor extra samples)
2905
+ 0x41 , 0x00 , 0x0c , 0x00 ,
2906
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 ,
2907
+ // Sentinel
2908
+ 0x01 , 0x00 , 0x00 , 0x00
2909
+ };
2910
+
2911
+ CDRMessage_t msg (0 );
2912
+ msg.init (data_w_buffer, static_cast <uint32_t >(sizeof (data_w_buffer)));
2913
+ msg.length = msg.max_size ;
2914
+
2915
+ WriterProxyData wpd (max_unicast_locators, max_multicast_locators);
2916
+ EXPECT_NO_THROW (EXPECT_TRUE (wpd.read_from_cdr_message (&msg, c_VendorId_eProsima)));
2917
+
2918
+ ASSERT_TRUE (wpd.resource_limits );
2919
+ ASSERT_EQ (wpd.resource_limits ->max_samples , 1 );
2920
+ ASSERT_EQ (wpd.resource_limits ->max_instances , 2 );
2921
+ ASSERT_EQ (wpd.resource_limits ->max_samples_per_instance , 3 );
2922
+ // Allocated samples and extra samples should have default values as they are not present in the data
2923
+ dds::ResourceLimitsQosPolicy default_values {};
2924
+ ASSERT_EQ (wpd.resource_limits ->allocated_samples , default_values.allocated_samples );
2925
+ ASSERT_EQ (wpd.resource_limits ->extra_samples , default_values.extra_samples );
2926
+ }
2927
+
2776
2928
/* *
2777
2929
* This test checks that a correct serialization is obtained
2778
2930
* when non-default eProsima's optional qos extensions are used in ReaderProxyData.
0 commit comments