1 /* 2 Copyright (c) 2020-2021 Intel Corporation 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 #if __INTEL_COMPILER && _MSC_VER 18 #pragma warning(disable : 2586) // decorated name length exceeded, name was truncated 19 #endif 20 21 #include "conformance_flowgraph.h" 22 23 //! \file conformance_broadcast_node.cpp 24 //! \brief Test for [flow_graph.broadcast_node] specification 25 26 using input_msg = conformance::message</*default_ctor*/false, /*copy_ctor*/true/*enable for queue_node successor*/, /*copy_assign*/true/*enable for queue_node successor*/>; 27 28 //! Test function_node broadcast 29 //! \brief \ref requirement 30 TEST_CASE("broadcast_node broadcasts"){ 31 conformance::test_forwarding<oneapi::tbb::flow::broadcast_node<int>, int>(1); 32 conformance::test_forwarding<oneapi::tbb::flow::broadcast_node<input_msg>, input_msg>(1); 33 } 34 35 //! Test broadcast_node buffering 36 //! \brief \ref requirement 37 TEST_CASE("broadcast_node buffering"){ 38 conformance::test_buffering<oneapi::tbb::flow::broadcast_node<int>, int>(); 39 } 40 41 //! Test inheritance relations 42 //! \brief \ref interface 43 TEST_CASE("broadcast_node superclasses"){ 44 conformance::test_inheritance<oneapi::tbb::flow::broadcast_node<int>, int, int>(); 45 conformance::test_inheritance<oneapi::tbb::flow::broadcast_node<float>, float, float>(); 46 conformance::test_inheritance<oneapi::tbb::flow::broadcast_node<input_msg>, input_msg, input_msg>(); 47 } 48 49 //! The node that is constructed has a reference to the same graph object as src. 50 //! The predecessors and successors of src are not copied. 51 //! \brief \ref interface 52 TEST_CASE("broadcast_node copy constructor"){ 53 using namespace oneapi::tbb::flow; 54 graph g; 55 56 broadcast_node<int> node0(g); 57 broadcast_node<int> node1(g); 58 conformance::test_push_receiver<int> node2(g); 59 conformance::test_push_receiver<int> node3(g); 60 61 oneapi::tbb::flow::make_edge(node0, node1); 62 oneapi::tbb::flow::make_edge(node1, node2); 63 64 broadcast_node<int> node_copy(node1); 65 66 oneapi::tbb::flow::make_edge(node_copy, node3); 67 68 node_copy.try_put(1); 69 g.wait_for_all(); 70 71 CHECK_MESSAGE((conformance::get_values(node2).size() == 0 && conformance::get_values(node3).size() == 1), "Copied node doesn`t copy successor"); 72 73 node0.try_put(1); 74 g.wait_for_all(); 75 76 CHECK_MESSAGE((conformance::get_values(node2).size() == 1 && conformance::get_values(node3).size() == 0), "Copied node doesn`t copy predecessor"); 77 } 78