Doxygen changes
[ACE_TAO.git] / ACE / tests / Compiler_Features_02_Test.cpp
blobf1e31f20b0d1150d9dd7be0af156e0847d090cb5
1 /**
2 * @file
4 * This program checks if the compiler / platform supports the
5 * std::map container. The motivation for this test was a discussion
6 * on the development mailing list, and the documentation was captured
7 * in:
9 * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3715
12 #include "test_config.h"
14 // The first part of the test is to compile this line. If the program
15 // does not compile the platform is just too broken.
16 #include <map>
18 int
19 run_main (int, ACE_TCHAR *[])
21 ACE_START_TEST (ACE_TEXT("Compiler_Features_02_Test"));
23 // As usual, the exit status from the test is 0 on success, 1 on
24 // failure
25 int status = 0;
27 // Create a simple list ...
28 typedef std::map<int,int> collection;
29 collection c;
31 // ... insert some elements ...
32 c[1] = 5;
33 c[2] = 4;
34 c[3] = 3;
35 c[4] = 2;
36 c.insert(collection::value_type(5, 1));
38 // ... inserting twice returns a pair ...
39 std::pair<collection::iterator,bool> r =
40 c.insert(collection::value_type(5, 0));
42 // ... the iterator points to the element ...
43 if (r.first->first != 5 || r.first->second != 1)
45 status = 1;
46 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected to find (5,1) already in map")));
49 // ... and the booleans says that it is already in the map ...
50 if (r.second == true)
52 status = 1;
53 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected duplicate insert to fail")));
56 // ... add all the numbers to validate that they are there ...
57 int sum = 0;
58 for(collection::iterator i = c.begin(), end = c.end();
59 i != end;
60 ++i)
62 sum += i->second;
65 // ... remember Euler ...
66 int const expected = 5*(5+1)/2;
67 if (sum != expected)
69 status = 1;
70 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected %d got %d\n"),
71 expected, sum));
74 ACE_END_TEST;
75 return status;