Revision 1249

trunk/tests/gtests/test_df1b2atan2.cpp (revision 1249)
1
#include <gtest/gtest.h>
2
#include <df1b2fun.h>
3
#include <cmath>
4

  
5
class test_df1b2atan2 :public ::testing::Test {};
6

  
7
TEST_F(test_df1b2atan2, should_fail_df1b2variable_null_constructor)
8
{
9
  ASSERT_ANY_THROW(df1b2variable y);
10
}
11
TEST_F(test_df1b2atan2, noallocate_df1b2variable_null_constructor)
12
{
13
  df1b2variable::noallocate = 1;
14
  df1b2variable y;
15
}
16
TEST_F(test_df1b2atan2, noallocate_df1b2variable_null_constructor_allocate)
17
{
18
  df1b2variable::noallocate = 1;
19
  df1b2variable y;
20
  ASSERT_ANY_THROW(y.allocate());
21
}
22
TEST_F(test_df1b2atan2, adpool_default_constructor)
23
{
24
  adpool pool;
25
  ASSERT_EQ(0, pool.head);
26
  ASSERT_EQ(0, pool.size);
27
}
28
TEST_F(test_df1b2atan2, adpool_default_constructor_grow)
29
{
30
  adpool pool;
31
  pool.set_size(808);
32
  pool.grow();
33

  
34
  const int overhead = 12 + sizeof(char*);
35
  const int chunk_size = 16 * 65000 - overhead;
36
  int expected_nelem = chunk_size / 808;
37
  ASSERT_EQ(expected_nelem, pool.nelem);
38
}
39
TEST_F(test_df1b2atan2, should_fail_adpool_alloc)
40
{
41
  adpool pool;
42
  pool.set_size(808);
43
  pool.alloc();
44
}
45
TEST_F(test_df1b2atan2, default_constructor_deallocate)
46
{
47
  df1b2variable::noallocate = 1;
48
  df1b2variable y;
49
  ASSERT_EQ(0, y.ptr);
50

  
51
  adpool pool;
52
  df1b2variable::pool = &pool;
53
  pool.set_size(808);
54
  df1b2_gradlist::no_derivatives = 1;
55
  y.ptr = (double*)pool.alloc();
56

  
57
  ASSERT_EQ(0, y.ncopies);
58
  y.deallocate();
59
  ASSERT_EQ(0, y.ptr);
60
}
61
TEST_F(test_df1b2atan2, default_constructor_initialize_int)
62
{
63
  df1b2variable::noallocate = 1;
64
  df1b2variable y;
65
  ASSERT_EQ(0, y.ptr);
66

  
67
  adpool pool;
68
  df1b2variable::pool = &pool;
69
  pool.set_size(808);
70
  df1b2_gradlist::no_derivatives = 1;
71
  y.ptr = (double*)pool.alloc();
72

  
73
  y.initialize(808);
74
}
75
TEST_F(test_df1b2atan2, default_constructor_initialize)
76
{
77
  df1b2variable::noallocate = 1;
78
  df1b2variable y;
79
  ASSERT_EQ(0, y.ptr);
80

  
81
  adpool pool;
82
  df1b2variable::pool = &pool;
83
  pool.set_size(808);
84
  pool.nvar = 808;
85
  df1b2_gradlist::no_derivatives = 1;
86
  y.ptr = (double*)pool.alloc();
87

  
88
  y.initialize();
89
}
90
TEST_F(test_df1b2atan2, default_constructor_allocate)
91
{
92
  df1b2variable::noallocate = 1;
93
  df1b2variable y;
94
  ASSERT_EQ(0, y.ptr);
95

  
96
  adpool pool;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff