<commit_before>/**
 * This file is part of the CernVM File System.
 */


#include <gtest/gtest.h>
#include <limits>

#include "../../cvmfs/smalloc.h"


const size_t kSmallAllocation = 1024UL;
const size_t kBigAllocation = std::numeric_limits<size_t>::max();

TEST(T_Smalloc, SmallAlloc) {
  void *mem = smalloc(kSmallAllocation);
  EXPECT_NE(static_cast<void*>(NULL), mem);
  free(mem);
}

TEST(T_Smalloc, BigAlloc) {
  void *mem = NULL;
  EXPECT_DEATH(mem = smalloc(kBigAllocation), ".*");
  EXPECT_EQ(static_cast<void*>(NULL), mem);
}

TEST(T_Smalloc, SmallRealloc) {
  void *mem = smalloc(kSmallAllocation);
  mem = srealloc(mem, kSmallAllocation * 2);
  EXPECT_NE(static_cast<void*>(NULL), mem);
  mem = srealloc(mem, kSmallAllocation / 2);
  EXPECT_NE(static_cast<void*>(NULL), mem);
  free(mem);
}

TEST(T_Smalloc, BigRealloc) {
  UniquePtr<void> mem(smalloc(kSmallAllocation));
  ASSERT_DEATH(mem = srealloc(mem, kBigAllocation), ".*");
  EXPECT_NE(static_cast<void*>(NULL), mem);
}
<commit_msg>FIX: add tutil.h to t_smalloc.cc<commit_after>/**
 * This file is part of the CernVM File System.
 */


#include <gtest/gtest.h>
#include <limits>

#include "../../cvmfs/smalloc.h"
#include "../../cvmfs/util.h"


const size_t kSmallAllocation = 1024UL;
const size_t kBigAllocation = std::numeric_limits<size_t>::max();

TEST(T_Smalloc, SmallAlloc) {
  void *mem = smalloc(kSmallAllocation);
  EXPECT_NE(static_cast<void*>(NULL), mem);
  free(mem);
}

TEST(T_Smalloc, BigAlloc) {
  void *mem = NULL;
  EXPECT_DEATH(mem = smalloc(kBigAllocation), ".*");
  EXPECT_EQ(static_cast<void*>(NULL), mem);
}

TEST(T_Smalloc, SmallRealloc) {
  void *mem = smalloc(kSmallAllocation);
  mem = srealloc(mem, kSmallAllocation * 2);
  EXPECT_NE(static_cast<void*>(NULL), mem);
  mem = srealloc(mem, kSmallAllocation / 2);
  EXPECT_NE(static_cast<void*>(NULL), mem);
  free(mem);
}

TEST(T_Smalloc, BigRealloc) {
  UniquePtr<void> mem(smalloc(kSmallAllocation));
  ASSERT_DEATH(mem = srealloc(mem, kBigAllocation), ".*");
  EXPECT_NE(static_cast<void*>(NULL), mem.weak_ref());
}

{'fraction_non_alphanumeric': 0.17005813953488372, 'fraction_numerical': 0.005813953488372093, 'mean_word_length': 5.576433121019108, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '787494', 'n_tokens_mistral': 806, 'n_tokens_neox': 802, 'n_words': 142}