Use override/default for RTPortableServer
[ACE_TAO.git] / ACE / tests / Compiler_Features_06_Test.cpp
blob3fde520fb71c76d6eab01e7e5745ce2436c488f3
1 /**
2 * @file
4 * This program checks if the compiler / platform supports alternative
5 * sorting functions in the std::set container. The motivation for
6 * this test was a discussion on the development mailing list, and the
7 * documentation was captured
8 * in:
10 * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3715
13 #include "test_config.h"
15 // The first part of the test is to compile this line. If the program
16 // does not compile the platform is just too broken.
17 #include <set>
19 // We are going to use std::greater<>, the spec requires us to include this
20 // header. Only a few platforms enforce this though...
21 #include <functional>
23 int
24 run_main (int, ACE_TCHAR *[])
26 ACE_START_TEST (ACE_TEXT("Compiler_Features_06_Test"));
28 // As usual, the exit status from the test is 0 on success, 1 on
29 // failure
30 int status = 0;
32 // Create a simple list ...
33 using collection = std::set<int, std::greater<int>>;
34 collection c;
36 // ... insert some elements ...
37 c.insert(5);
38 c.insert(4);
39 c.insert(3);
40 c.insert(2);
41 c.insert(1);
43 // ... inserting twice returns a pair ...
44 std::pair<collection::iterator,bool> r =
45 c.insert(collection::value_type(5));
47 // ... the iterator points to the element ...
48 if (*r.first != 5)
50 status = 1;
51 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected to find 5 already in set")));
54 // ... and the booleans says that it is already in the set ...
55 if (r.second == true)
57 status = 1;
58 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected duplicate insert to fail")));
61 // ... make sure the first element is the biggest one ...
62 if (5 != *c.begin())
64 status = 1;
65 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected largest element (5) at the front")));
68 // ... add all the numbers to validate that they are there ...
69 int sum = 0;
70 for(collection::iterator i = c.begin(), end = c.end();
71 i != end;
72 ++i)
74 sum += *i;
77 // ... remember Euler ...
78 int const expected = 5*(5+1)/2;
79 if (sum != expected)
81 status = 1;
82 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected %d got %d\n"),
83 expected, sum));
86 ACE_END_TEST;
87 return status;