File: debug_rel.cpp

package info (click to toggle)
cppad 2025.00.00.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,552 kB
  • sloc: cpp: 112,594; sh: 5,972; ansic: 179; python: 71; sed: 12; makefile: 10
file content (69 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
// SPDX-FileContributor: 2003-22 Bradley M. Bell
// ----------------------------------------------------------------------------

// system include files used for I/O
# include <iostream>

// for free_all
# include <cppad/utility/thread_alloc.hpp>

namespace {
   size_t n_ok    = 0;
   size_t n_error = 0;
   void print_test(bool ok, const char* name)
   {
      std::cout.width(20);
      std::cout.setf( std::ios_base::left );
      std::cout << name;
      //
      if( ok )
      {  std::cout << "OK\n";
         n_ok++;
      }
      else
      {  std::cout << "Error\n";
         n_error++;
      }
   }
}

// thread_alloc
double *release_thread_alloc(void);
bool      debug_thread_alloc(double* d_ptr);

// adfun_ctor
void debug_adfun_ctor(void);
void release_adfun_ctor(void);

// main program that runs all the tests
int main(void)
{  using std::cout;
   cout << "Begin test_more/debug_rel\n";
   //
   // thread_alloc
   {  double* d_ptr = release_thread_alloc();
      bool ok       = debug_thread_alloc(d_ptr);
      print_test(ok, "thead_alloc");
   }
   // adfun_ctor
   {  // this test would fail with an assert during release_adfun_ctor
      release_adfun_ctor();
      debug_adfun_ctor();
      bool ok = true;
      print_test(ok, "adfun_ctor");
   }
   // memory
   {  bool ok = CppAD::thread_alloc::free_all();
      print_test(ok, "memory");
   }
   if( n_error == 0 )
      std::cout << "All " << n_ok << " tests passed." << std::endl;
   else
      std::cout << n_error << " tests failed." << std::endl;
   //
   if( n_error == 0 )
      return 0;
   return 1;
}