From ef539937deb9820b70cf096fc65aead7c74c3470 Mon Sep 17 00:00:00 2001 From: "W. David Dagenhart" Date: Fri, 18 Nov 2022 18:37:59 +0100 Subject: [PATCH] Add check of put values to unit test --- FWCore/Integration/test/SwitchProducer_t.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/FWCore/Integration/test/SwitchProducer_t.cpp b/FWCore/Integration/test/SwitchProducer_t.cpp index ebf9eed89c0ae..464f0a242a2af 100644 --- a/FWCore/Integration/test/SwitchProducer_t.cpp +++ b/FWCore/Integration/test/SwitchProducer_t.cpp @@ -259,9 +259,23 @@ TEST_CASE("Configuration with different transient branches", s_tag) { SECTION("Different transient branches are allowed") { edm::test::TestProcessor::Config config1{baseConfig1}; edm::test::TestProcessor testProcessor1{config1}; + auto event1 = testProcessor1.test(); + REQUIRE(event1.get()->value == 2); + + // It would be better if the next line of executable code would + // throw an exception, but that is not the current expected behavior. + // It would be nice to have all cases of a SwitchProducer fail if + // any case fails on a "get" (but it is intentional and desirable + // that it does not fail only because a case declares it produces + // different transient products). We decided it was not worth the + // effort and complexity to implement this behavior (at least not yet). + REQUIRE(event1.get("foo")->value == 3); edm::test::TestProcessor::Config config2{baseConfig2}; edm::test::TestProcessor testProcessor2{config2}; + auto event2 = testProcessor2.test(); + REQUIRE(event2.get()->value == 1); + REQUIRE_THROWS(event2.get()->value == 3); } }