source: trunk/test_more/adfun_copy.cpp @ 3520

Last change on this file since 3520 was 3519, checked in by bradbell, 5 years ago
  1. Fix some clang 3.5 warnings about local functions that were not used.
  2. Change ndebug -> adfun_copy and test error on ADFun copy constructor usage.

CMakeLists.txt: remove duplicate compliation of eigen_soruces.
makefile.am: :

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1/* $Id: adfun_copy.cpp 3519 2014-12-28 16:22:57Z bradbell $ */
2/* --------------------------------------------------------------------------
3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
4
5CppAD is distributed under multiple licenses. This distribution is under
6the terms of the
7                    Eclipse Public License Version 1.0.
8
9A copy of this license is included in the COPYING file of this distribution.
10Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11-------------------------------------------------------------------------- */
12
13/*
14Test that ADFun copy constructor generates an error message.
15*/
16
17# include <cppad/cppad.hpp>
18# include <string>
19
20namespace {
21
22        // error handler to catch the error
23        void myhandler(
24                bool known       ,
25                int  line        ,
26                const char *file ,
27                const char *exp  ,
28                const char *msg  )
29        {       // error handler must not return, so throw an exception
30                throw std::string("myhandler");
31        }
32
33}
34
35bool adfun_copy(void)
36{
37        // error handler for this routine
38        CppAD::ErrorHandler info(myhandler);
39        // an ADFun object
40        CppAD::ADFun<double> f;
41        // value of ok if no error occurs
42        bool ok = false;
43        try {
44                // This operation uses the ADFun copy constructor which is defined,
45                // but should not be used and should generate an error
46                CppAD::ADFun<double> g(f);
47        }
48        catch ( std::string msg )
49        {       // check for expected return
50                ok = (msg == "myhandler");
51        }
52        return ok;
53}
Note: See TracBrowser for help on using the repository browser.