<commit_before>// -*- Mode:C++ -*-

/**************************************************************************************************/
/*                                                                                                */
/* Copyright (C) 2014 University of Hull                                                          */
/*                                                                                                */
/**************************************************************************************************/
/*                                                                                                */
/*  module     :  field/test/adapter_single.cpp                                                   */
/*  project    :                                                                                  */
/*  description:                                                                                  */
/*                                                                                                */
/**************************************************************************************************/

// includes, system

//#include <>

// includes, project

#include <field/adapter/single.hpp>
#include <shared.hpp>

// internal unnamed namespace

namespace {
  
  // types, internal (class, enum, struct, union, typedef)

  // variables, internal
  
  // functions, internal

} // namespace {

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/test/test_case_template.hpp>

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_get, T, field::test::single_types)
{
  using namespace field;

  test::container_single<T> c;
  adapter::single<T> const  f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));

  BOOST_CHECK(T() == f.get());
}

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_set, T, field::test::single_types)
{
  using namespace field;
  
  test::container_single<T> c;
  adapter::single<T>        f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));
  
  BOOST_CHECK(T() == f.set(T()));
}

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_op_convert, T, field::test::single_types)
{
  using namespace field;

  test::container_single<T> c;
  adapter::single<T> const  f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));
    
  BOOST_CHECK(T() == static_cast<T const&>(f));
  BOOST_CHECK(T() == static_cast<T>(f));
}

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_op_assign, T, field::test::single_types)
{
  using namespace field;
  
  test::container_single<T> c;
  adapter::single<T>        f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));
  
  BOOST_CHECK(T() == static_cast<T>(f = T()));
}
<commit_msg>fixed: compile errors<commit_after>// -*- Mode:C++ -*-

/**************************************************************************************************/
/*                                                                                                */
/* Copyright (C) 2014 University of Hull                                                          */
/*                                                                                                */
/**************************************************************************************************/
/*                                                                                                */
/*  module     :  field/test/adapter_single.cpp                                                   */
/*  project    :                                                                                  */
/*  description:                                                                                  */
/*                                                                                                */
/**************************************************************************************************/

// includes, system

//#include <>

// includes, project

#include <field/adapter/single.hpp>
#include <shared.hpp>

// internal unnamed namespace

namespace {
  
  // types, internal (class, enum, struct, union, typedef)

  // variables, internal
  
  // functions, internal

} // namespace {

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/test/test_case_template.hpp>

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_get, T, field::test::single_types)
{
  using namespace field;

  test::container_single<T> c;
  adapter::single<T> const  f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));

  BOOST_CHECK(T() == f.get());
}

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_set, T, field::test::single_types)
{
  using namespace field;
  
  test::container_single<T> c;
  adapter::single<T>        f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));
  
  BOOST_CHECK(T() == f.set(T()));
}

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_op_convert, T, field::test::single_types)
{
  using namespace field;

  test::container_single<T> c;
  adapter::single<T> const  f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));
    
  BOOST_CHECK(T() == static_cast<T const&>(f));
  // BOOST_CHECK(T() == static_cast<T>(f));
}

BOOST_AUTO_TEST_CASE_TEMPLATE(adapter_single_op_assign, T, field::test::single_types)
{
  using namespace field;
  
  test::container_single<T> c;
  adapter::single<T>        f(c, "f",
                              std::bind(&test::container_single<T>::cb_get, &c),
                              std::bind(&test::container_single<T>::cb_set, &c,
                                        std::placeholders::_1));
  
  BOOST_CHECK(T() == static_cast<T const&>(f = T()));
}

{'fraction_non_alphanumeric': 0.2065439672801636, 'fraction_numerical': 0.0023371311714869996, 'mean_word_length': 1.4673873873873873, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1197602', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1610, 'n_words': 245}