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

Public Member Functions

 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()

MessageTagTest::CPPUNIT_TEST_SUITE ( MessageTagTest  )

◆ CPPUNIT_TEST_SUITE_END()

MessageTagTest::CPPUNIT_TEST_SUITE_END ( )

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

References TestCommWorld.

◆ testGetUniqueTagManual()

void MessageTagTest::testGetUniqueTagManual ( )
inline

Definition at line 74 of file message_tag.C.

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

References TestCommWorld.

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:
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111