@@ -160,6 +160,25 @@ TEST(PrivacyLossDistributionTest, Compose) {
160160 EXPECT_FALSE (pld->Pmf ().empty ());
161161}
162162
163+ TEST (PrivacyLossDistributionTest, GetDeltaForEpsilonForComposedPLD) {
164+ ProbabilityMassFunction pmf = {{0 , 0.1 }, {1 , 0.7 }, {2 , 0.1 }};
165+ std::unique_ptr<PrivacyLossDistribution> pld =
166+ PrivacyLossDistributionTestPeer::Create (pmf,
167+ /* infinity_mass=*/ 0.1 ,
168+ /* discretization_interval=*/ 0.4 );
169+
170+ ProbabilityMassFunction pmf_other = {{1 , 0.1 }, {2 , 0.6 }, {3 , 0.25 }};
171+ std::unique_ptr<PrivacyLossDistribution> pld_other =
172+ PrivacyLossDistributionTestPeer::Create (pmf_other,
173+ /* infinity_mass=*/ 0.05 ,
174+ /* discretization_interval=*/ 0.4 );
175+
176+ base::StatusOr<double > delta =
177+ pld->GetDeltaForEpsilonForComposedPLD (*pld_other, /* epsilon=*/ 1.1 );
178+ ASSERT_OK (delta);
179+ EXPECT_THAT (*delta, DoubleNear (0.2956 , kMaxError ));
180+ }
181+
163182TEST (PrivacyLossDistributionTest, ComposeTruncation) {
164183 ProbabilityMassFunction pmf = {{0 , 0.1 }, {1 , 0.7 }, {2 , 0.1 }};
165184 std::unique_ptr<PrivacyLossDistribution> pld =
@@ -209,10 +228,16 @@ TEST(PrivacyLossDistributionTest,
209228 std::unique_ptr<PrivacyLossDistribution> pld_other =
210229 PrivacyLossDistributionTestPeer::Create (pmf, 0.3 , 2e-4 );
211230
212- EXPECT_THAT (pld->Compose (*pld_other),
213- StatusIs (absl::InvalidArgumentError (" " ).code (),
214- HasSubstr (" Cannot compose, discretization intervals "
215- " are different - 0.000200 vs 0.000100" )));
231+ std::string error_msg = " discretization interval" ;
232+ EXPECT_THAT (
233+ pld->ValidateComposition (*pld_other),
234+ StatusIs (absl::StatusCode::kInvalidArgument , HasSubstr (error_msg)));
235+ EXPECT_THAT (
236+ pld->Compose (*pld_other),
237+ StatusIs (absl::StatusCode::kInvalidArgument , HasSubstr (error_msg)));
238+ EXPECT_THAT (
239+ pld->GetDeltaForEpsilonForComposedPLD (*pld_other, /* epsilon=*/ 1 ),
240+ StatusIs (absl::StatusCode::kInvalidArgument , HasSubstr (error_msg)));
216241}
217242
218243TEST (PrivacyLossDistributionTest, ComposeErrorDifferentEstimateTypes) {
@@ -227,9 +252,16 @@ TEST(PrivacyLossDistributionTest, ComposeErrorDifferentEstimateTypes) {
227252 pmf, /* infinity_mass=*/ 0.3 , /* discretization_interval=*/ 1e-4 ,
228253 /* estimate_type=*/ EstimateType::kOptimistic );
229254
230- EXPECT_THAT (pld->Compose (*pld_other),
231- StatusIs (absl::StatusCode::kInvalidArgument ,
232- Eq (" Cannot compose, estimate types are different" )));
255+ std::string error_msg = " estimate type" ;
256+ EXPECT_THAT (
257+ pld->ValidateComposition (*pld_other),
258+ StatusIs (absl::StatusCode::kInvalidArgument , HasSubstr (error_msg)));
259+ EXPECT_THAT (
260+ pld->Compose (*pld_other),
261+ StatusIs (absl::StatusCode::kInvalidArgument , HasSubstr (error_msg)));
262+ EXPECT_THAT (
263+ pld->GetDeltaForEpsilonForComposedPLD (*pld_other, /* epsilon=*/ 1 ),
264+ StatusIs (absl::StatusCode::kInvalidArgument , HasSubstr (error_msg)));
233265}
234266
235267struct GetEpsilonFromDeltaParam {
0 commit comments