diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-07-03 12:49:31 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-07-03 12:49:31 +0000 |
commit | 501cddaf4e9bec56bf88b22b3ebc5143e85a9ad7 (patch) | |
tree | 0969d1c137de37e225d14204cc37e0725559ad32 | |
parent | 4faef16792bd0a33274147315017578994a39eb5 (diff) | |
download | ATCD-501cddaf4e9bec56bf88b22b3ebc5143e85a9ad7.tar.gz |
Fri Jul 3 12:47:41 UTC 2009 Carlos O'Ryan <coryan@glamdring>
* tests/Compiler_Features_11_Test.cpp:
Test for standard string streams
* tests/Compiler_Features_12_Test.cpp:
Test for template template parameters
* tests/Compiler_Features_13_Test.cpp:
Test for cast operators
* tests/tests.mpc:
* tests/run_test.lst:
* tests/Makefile.am:
The usual accruements that go with the tests.
-rw-r--r-- | ACE/ChangeLog | 16 | ||||
-rw-r--r-- | ACE/tests/Compiler_Features_11_Test.cpp | 66 | ||||
-rw-r--r-- | ACE/tests/Compiler_Features_12_Test.cpp | 59 | ||||
-rw-r--r-- | ACE/tests/Compiler_Features_13_Test.cpp | 145 | ||||
-rw-r--r-- | ACE/tests/Makefile.am | 60 | ||||
-rw-r--r-- | ACE/tests/run_test.lst | 4 | ||||
-rw-r--r-- | ACE/tests/tests.mpc | 21 |
7 files changed, 370 insertions, 1 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 9cb21e7a093..f6d1f4455ab 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,19 @@ +Fri Jul 3 12:47:41 UTC 2009 Carlos O'Ryan <coryan@glamdring> + + * tests/Compiler_Features_11_Test.cpp: + Test for standard string streams + + * tests/Compiler_Features_12_Test.cpp: + Test for template template parameters + + * tests/Compiler_Features_13_Test.cpp: + Test for cast operators + + * tests/tests.mpc: + * tests/run_test.lst: + * tests/Makefile.am: + The usual accruements that go with the tests. + Fri Jul 3 03:03:56 UTC 2009 Carlos O'Ryan <coryan@glamdring> * tests/run_test.lst: diff --git a/ACE/tests/Compiler_Features_11_Test.cpp b/ACE/tests/Compiler_Features_11_Test.cpp new file mode 100644 index 00000000000..da5875c1a7b --- /dev/null +++ b/ACE/tests/Compiler_Features_11_Test.cpp @@ -0,0 +1,66 @@ +// $Id$ + +/** + * @file + * + * This program checks if the compiler / platform supports the + * string steams. The motivation for this test was a discussion + * on the development mailing list, and the documentation was captured + * in: + * + * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3715 + * + */ + +#include "test_config.h" + +// The first part of the test is to compile this line. If the program +// does not compile the platform is just too broken. +#include <sstream> + +ACE_RCSID(tests, Compiler_Features_11_Test, "$Id$") + +int +run_main (int, ACE_TCHAR *[]) +{ + ACE_START_TEST (ACE_TEXT("Compiler_Features_11_Test")); + + // As usual, the exit status from the test is 0 on success, 1 on + // failure + int status = 0; + + // Test creation of a output stream ... + std::ostringstream os; + + // ... add some strings and numbers to it ... + os << "1" << 2 << 3 << "45"; + + // ... verify the right thing comes out ... + std::string const expected("12345"); + if (os.str() != expected) + { + status = 1; + ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected %s got %s\n"), + expected.c_str(), os.str().c_str())); + } + + // ... create an input stream from the result ... + std::istringstream is(os.str()); + + // ... extract as a number ... + int v; + is >> v; + + // ... verify the right thing comes out ... + if (v != 12345) + { + status = 1; + ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected %d got %d\n"), + 12345, v)); + } + + ACE_END_TEST; + return status; +} + + diff --git a/ACE/tests/Compiler_Features_12_Test.cpp b/ACE/tests/Compiler_Features_12_Test.cpp new file mode 100644 index 00000000000..ffe095d6010 --- /dev/null +++ b/ACE/tests/Compiler_Features_12_Test.cpp @@ -0,0 +1,59 @@ +// $Id$ + +/** + * @file + * + * This program checks if the compiler / platform supports template + * template parameters. The motivation for this test was a discussion + * on the development mailing list, and the documentation was captured + * in: + * + * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3715 + * + */ + +#include "test_config.h" + +ACE_RCSID(tests, Compiler_Features_12_Test, "$Id$") + +template<typename T> +struct pair +{ + T x1; + T x2; +}; + +template<typename T> +struct triple +{ + T t1; + T t2; + T t3; +}; + +template<typename T, template <typename> class Tuple> +struct Array +{ + Tuple<T> array[5]; +}; + +int +run_main (int, ACE_TCHAR *[]) +{ + ACE_START_TEST (ACE_TEXT("Compiler_Features_12_Test")); + + // As usual, the exit status from the test is 0 on success, 1 on + // failure + int status = 0; + + Array<int, pair> pairs; + pairs.array[0].x1 = 0; + + Array<int, triple> triples; + triples.array[1].t3 = 0; + + ACE_END_TEST; + return status; +} + + diff --git a/ACE/tests/Compiler_Features_13_Test.cpp b/ACE/tests/Compiler_Features_13_Test.cpp new file mode 100644 index 00000000000..f9f4317cbfc --- /dev/null +++ b/ACE/tests/Compiler_Features_13_Test.cpp @@ -0,0 +1,145 @@ +// $Id$ + +/** + * @file + * + * This program checks if the compiler / platform supports the + * standard cast operators template parameters. The motivation for + * this test was a discussion on the development mailing list, and the + * documentation was captured in: + * + * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3715 + * + */ + +#include "test_config.h" + +#include <stdexcept> + +ACE_RCSID(tests, Compiler_Features_13_Test, "$Id$") + +namespace +{ + /** + * Helper class for test + */ + struct Base + { + virtual ~Base() + {} + }; + + /** + * Helper class for test + */ + struct Derived : public Base + { + int value; + }; + + /** + * Helper class for test + */ + struct Another : public Base + { + int x; + int y; + }; +} + + +int +run_main (int, ACE_TCHAR *[]) +{ + ACE_START_TEST (ACE_TEXT("Compiler_Features_13_Test")); + + // As usual, the exit status from the test is 0 on success, 1 on + // failure + int status = 0; + + { + // Make sure const cast works. Compilation is interesting, the + // functionality test here is just to make sure the compiler does + // not optimize things away ... + int x = 5; + int const & y = x; + const_cast<int&>(y) = 3; + + if (x != 3) + { + status = 1; + ACE_ERROR((LM_ERROR, + ACE_TEXT("Wrong value after const_cast," + " expected %d, got %d\n"), + 3, x)); + } + } + + // Make sure dynamic cast through pointers work ... + Derived d; + d.value = 24; + Base * b1 = &d; + Derived * d1 = dynamic_cast<Derived*>(b1); + if (d1 == 0) + { + status = 1; + ACE_ERROR((LM_ERROR, + ACE_TEXT("dynamic_cast returns null, expected value\n"))); + } + d1->value = 42; + if (d.value != 42) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT("Wrong value after dynamic_cast, expected %d, got %d\n"), + 42, d.value)); + } + + // Make sure dynamic cast detects invalid casts + Another a; + Base * b2 = &a; + Derived * d2 = dynamic_cast<Derived*>(b2); + if (d2 != 0) + { + status = 1; + ACE_ERROR((LM_ERROR, + ACE_TEXT("dynamic_cast should return null\n"))); + } + + // Make sure dynamic cast raises an exception + Base & b3 = a; + try + { + (void) dynamic_cast<Derived&>(b3); + + status = 1; + ACE_ERROR((LM_ERROR, + ACE_TEXT("dynamic_cast should have raised exception\n"))); + } + catch(std::exception const &) + { + } + catch(...) + { + status = 1; + ACE_ERROR((LM_ERROR, + ACE_TEXT("dynamic_cast should have raised std::exception\n"))); + } + + { + // Just test these compile ... + double x = 42.0; + int y = static_cast<int>(x); + void * z = reinterpret_cast<void*>(y); + + if (z == 0) + { + ACE_ERROR((LM_ERROR, + ACE_TEXT("My hack to make sure the code is not " + "optimized away backfired!\n"))); + } + } + + ACE_END_TEST; + return status; +} + diff --git a/ACE/tests/Makefile.am b/ACE/tests/Makefile.am index 74a2882126e..cac688be617 100644 --- a/ACE/tests/Makefile.am +++ b/ACE/tests/Makefile.am @@ -843,6 +843,66 @@ Compiler_Features_10_Test_LDADD = \ endif !BUILD_ACE_FOR_TAO +## Makefile.Compiler_Features_11_Test.am + +if !BUILD_ACE_FOR_TAO + +noinst_PROGRAMS += Compiler_Features_11_Test + +Compiler_Features_11_Test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) + +Compiler_Features_11_Test_SOURCES = \ + $(ACE_ROOT)/tests/Main.cpp \ + Compiler_Features_11_Test.cpp \ + +Compiler_Features_11_Test_LDADD = \ + libTest_Output.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_ACE_FOR_TAO + +## Makefile.Compiler_Features_12_Test.am + +if !BUILD_ACE_FOR_TAO + +noinst_PROGRAMS += Compiler_Features_12_Test + +Compiler_Features_12_Test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) + +Compiler_Features_12_Test_SOURCES = \ + $(ACE_ROOT)/tests/Main.cpp \ + Compiler_Features_12_Test.cpp \ + +Compiler_Features_12_Test_LDADD = \ + libTest_Output.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_ACE_FOR_TAO + +## Makefile.Compiler_Features_13_Test.am + +if !BUILD_ACE_FOR_TAO + +noinst_PROGRAMS += Compiler_Features_13_Test + +Compiler_Features_13_Test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) + +Compiler_Features_13_Test_SOURCES = \ + $(ACE_ROOT)/tests/Main.cpp \ + Compiler_Features_13_Test.cpp \ + +Compiler_Features_13_Test_LDADD = \ + libTest_Output.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_ACE_FOR_TAO + ## Makefile.Config_Test.am if !BUILD_ACE_FOR_TAO diff --git a/ACE/tests/run_test.lst b/ACE/tests/run_test.lst index ba963edd98f..d2fb7e471d3 100644 --- a/ACE/tests/run_test.lst +++ b/ACE/tests/run_test.lst @@ -70,7 +70,9 @@ Compiler_Features_06_Test Compiler_Features_07_Test Compiler_Features_08_Test Compiler_Features_09_Test -Compiler_Features_10_Test +Compiler_Features_11_Test +Compiler_Features_12_Test +Compiler_Features_13_Test Config_Test: !LynxOS !VxWorks !ACE_FOR_TAO Conn_Test: !ACE_FOR_TAO DLL_Test: !Unicos !STATIC !KCC_Linux diff --git a/ACE/tests/tests.mpc b/ACE/tests/tests.mpc index 4f54ee75522..b6c115eb9ee 100644 --- a/ACE/tests/tests.mpc +++ b/ACE/tests/tests.mpc @@ -506,6 +506,27 @@ project(Compiler_Features_10_Test) : acetest { } } +project(Compiler_Features_11_Test) : acetest { + exename = Compiler_Features_11_Test + Source_Files { + Compiler_Features_11_Test.cpp + } +} + +project(Compiler_Features_12_Test) : acetest { + exename = Compiler_Features_12_Test + Source_Files { + Compiler_Features_12_Test.cpp + } +} + +project(Compiler_Features_13_Test) : acetest { + exename = Compiler_Features_13_Test + Source_Files { + Compiler_Features_13_Test.cpp + } +} + project(Config Test) : acetest { avoids += ace_for_tao exename = Config_Test |