libMesh
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
MessageTagTest Class Reference
Inheritance diagram for MessageTagTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (MessageTagTest)
 
 CPPUNIT_TEST (testGetUniqueTagAuto)
 
 CPPUNIT_TEST (testGetUniqueTagManual)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testGetUniqueTagAuto ()
 
void testGetUniqueTagManual ()
 

Private Attributes

std::vector< std::string > _number
 

Detailed Description

Definition at line 13 of file message_tag.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/2]

MessageTagTest::CPPUNIT_TEST ( testGetUniqueTagAuto  )

◆ CPPUNIT_TEST() [2/2]

MessageTagTest::CPPUNIT_TEST ( testGetUniqueTagManual  )

◆ CPPUNIT_TEST_SUITE_END()

MessageTagTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

MessageTagTest::LIBMESH_CPPUNIT_TEST_SUITE ( MessageTagTest  )

◆ setUp()

void MessageTagTest::setUp ( )
inline

Definition at line 26 of file message_tag.C.

27 {}

◆ tearDown()

void MessageTagTest::tearDown ( )
inline

Definition at line 29 of file message_tag.C.

30 {}

◆ testGetUniqueTagAuto()

void MessageTagTest::testGetUniqueTagAuto ( )
inline

Definition at line 34 of file message_tag.C.

35 {
36 LOG_UNIT_TEST;
37
38 // We need to explicitly duplicate the communicator first, because
39 // the original might already have tags used by other unit tests
40
42
43 newcomm.duplicate(*TestCommWorld);
44
45 const int n_vals = 5;
46 const int n_vals_in_scope = 3;
47 std::vector<int> vals(n_vals);
48
49 {
50 std::vector<Parallel::MessageTag> tags(n_vals_in_scope);
51 for (int i=0; i != n_vals_in_scope; ++i)
52 {
53 tags[i] = newcomm.get_unique_tag();
54 vals[i] = tags[i].value();
55 for (int j=0; j != i; ++j)
56 {
57 CPPUNIT_ASSERT(vals[i] != vals[j]);
58 }
59 }
60 }
61
62 // Even after we go out of scope those values should be used up
63 for (int i=n_vals_in_scope; i != n_vals; ++i)
64 {
65 Parallel::MessageTag another_tag = newcomm.get_unique_tag();
66 vals[i] = another_tag.value();
67 for (int j=0; j != i; ++j)
68 {
69 CPPUNIT_ASSERT(vals[i] != vals[j]);
70 }
71 }
72 }
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
void duplicate(const Communicator &comm)
int value() const

References libMesh::Parallel::Communicator::duplicate(), libMesh::Parallel::Communicator::get_unique_tag(), TestCommWorld, and TIMPI::MessageTag::value().

◆ testGetUniqueTagManual()

void MessageTagTest::testGetUniqueTagManual ( )
inline

Definition at line 76 of file message_tag.C.

77 {
78 LOG_UNIT_TEST;
79
80 // Here we'll use the standard communicator, because even if it
81 // used these tags in other contexts it should have freed them for
82 // reuse later.
83
84 const int requests[] = {2, 4, 6, 8, 8, 6, 8, 123, 3141, 3142};
85
86 for (const int i : requests)
87 {
88 Parallel::MessageTag manual_tag =
89 TestCommWorld->get_unique_tag(i);
90 CPPUNIT_ASSERT_EQUAL(i, manual_tag.value());
91 }
92 }
Communicator * TestCommWorld

References TestCommWorld, and TIMPI::MessageTag::value().

Member Data Documentation

◆ _number

std::vector<std::string> MessageTagTest::_number
private

Definition at line 23 of file message_tag.C.


The documentation for this class was generated from the following file: