Revision 1308

trunk/tests/gtests/test_df_file.cpp (revision 1308)
37 37
{
38 38
  ASSERT_NO_THROW(DF_FILE instance(INT_MAX));
39 39
}
40
TEST_F(test_df_file, instance_INT_MAX_plus_1)
41
{
42
  ASSERT_NO_THROW(DF_FILE instance(INT_MAX + 1));
43
}
44
/*
40 45
TEST_F(test_df_file, allocate_INT_MAX_plus_1)
41 46
{
42 47
  ASSERT_LT(INT_MAX, LONG_MAX);
......
44 49
  ASSERT_EQ(SIZE_MAX, ULONG_MAX);
45 50
  size_t size = INT_MAX + 1;
46 51
  ASSERT_LT(size, SIZE_MAX);
47
  char* a = new char[size];
48
  if (a != 0)
52
  //Cannot allocate for size > INT_MAX 
53
  try
49 54
  {
50
    delete [] a;
51
    a = 0;
55
    new char[size];
52 56
  }
57
  catch(...)
58
  {
59
    return;
60
  }
61
  FAIL();
53 62
}
63
*/
64
TEST_F(test_df_file, write_read_int)
65
{
66
  DF_FILE buffer(sizeof(int));
67
  const int expected = __LINE__;
68
  buffer.fwrite(expected);
69
  int integer = 0;
70
  buffer.fread(integer);
71
  ASSERT_EQ(expected, integer);
72
}
73
TEST_F(test_df_file, write_read_int_3x)
74
{
75
  DF_FILE buffer(sizeof(int));
76

  
77
  const int expected = __LINE__;
78
  buffer.fwrite(expected);
79

  
80
  const int expected2 = __LINE__;
81
  buffer.fwrite(expected2);
82

  
83
  const int expected3 = __LINE__;
84
  buffer.fwrite(expected3);
85

  
86
  int integer3 = 0;
87
  buffer.fread(integer3);
88
  ASSERT_EQ(expected3, integer3);
89

  
90
  int integer2 = 0;
91
  buffer.fread(integer2);
92
  ASSERT_EQ(expected2, integer2);
93

  
94
  int integer = 0;
95
  buffer.fread(integer);
96
  ASSERT_EQ(expected, integer);
97
}
98
TEST_F(test_df_file, write_read_double)
99
{
100
  DF_FILE buffer(sizeof(double));
101
  const double expected = __LINE__;
102
  buffer.fwrite(expected);
103

  
104
  double number = 0;
105
  buffer.fread(number);
106
  ASSERT_EQ(expected, number);
107
}
108
TEST_F(test_df_file, write_read_char_array11)
109
{
110
  DF_FILE buffer(50);
111
  const char expected[11] = "12345-6789";
112
  buffer.fwrite(expected, 11);
113

  
114
  char array[11] = "\0";
115
  buffer.fread(&array[0], 11);
116
  ASSERT_STREQ(expected, array);
117
}
118
TEST_F(test_df_file, write_read_ptr)
119
{
120
  DF_FILE buffer(50);
121
  int expected = __LINE__;
122
  int* ptr = &expected;
123
  int* number = 0;
124
  //buffer.fwrite(ptr);
125
  //buffer.fread(number);
126
  ASSERT_EQ(&expected, number);
127
}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff