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

/**************************************************************************************************/
/*                                                                                                */
/* Copyright (C) 2014-2015 University of Hull                                                     */
/*                                                                                                */
/**************************************************************************************************/
/*                                                                                                */
/*  module     :  geometry/test/lattice.cpp                                                       */
/*  project    :                                                                                  */
/*  description:                                                                                  */
/*                                                                                                */
/**************************************************************************************************/

// includes, system

#include <glm/glm.hpp>    // glm::vec3
#include <glm/gtx/io.hpp> // glm::operator<<

// includes, project

#include <geometry/lattice.hpp>

#define UKACHULLDCS_USE_TRACE
#undef UKACHULLDCS_USE_TRACE
#include <support/trace.hpp>

// internal unnamed namespace

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

  // variables, internal

#if !defined(_MSC_VER) || (defined(_MSC_VER) && (_MSC_VER > 1800))
  constexpr
#endif
  unsigned const dflt[3] = { 5, 3, 2 };
  
  // functions, internal

} // namespace {

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

BOOST_AUTO_TEST_CASE(test_geometry_lattice_ctor)
{
  using ltype = geometry::lattice<glm::vec3, dflt[0], dflt[1], dflt[2]>;

  glm::vec3 const v(0,1,2);
  ltype const     l(v);
  
  BOOST_CHECK  (v == l.at(0,0,0));
}

BOOST_AUTO_TEST_CASE(test_geometry_lattice_print_on)
{
  using ltype = geometry::lattice<glm::vec3, 1, 2, 3>;

  ltype const l;
  
  BOOST_CHECK  (true);
  BOOST_MESSAGE(glm::io::precision(1) << glm::io::width(3) << l);
}

BOOST_AUTO_TEST_CASE(test_geometry_lattice_at)
{
  using ltype = geometry::lattice<glm::vec3, dflt[0], dflt[1], dflt[2]>;

  {
    ltype const l;
    
    BOOST_CHECK  (ltype::value_type() == l.at(0,0,0));
  }

  {
    glm::vec3 const v(1,-1,1);
    ltype           l;
    
    l.at(0,0,0) = v;
    
    BOOST_CHECK  (v == l.at(0,0,0));
  }

  {
    ltype l;
  
    BOOST_CHECK_THROW(l.at(dflt[0], dflt[1], dflt[2]), std::range_error);
  }

  {
    ltype const l;

    BOOST_CHECK_THROW(l.at(dflt[0], dflt[1], dflt[2]), std::range_error);<commit_msg>fixed: boost 1.59 compat<commit_after>// -*- Mode:C++ -*-

/**************************************************************************************************/
/*                                                                                                */
/* Copyright (C) 2014-2015 University of Hull                                                     */
/*                                                                                                */
/**************************************************************************************************/
/*                                                                                                */
/*  module     :  geometry/test/lattice.cpp                                                       */
/*  project    :                                                                                  */
/*  description:                                                                                  */
/*                                                                                                */
/**************************************************************************************************/

// includes, system

#include <glm/glm.hpp>    // glm::vec3
#include <glm/gtx/io.hpp> // glm::operator<<

// includes, project

#include <geometry/lattice.hpp>

#define UKACHULLDCS_USE_TRACE
#undef UKACHULLDCS_USE_TRACE
#include <support/trace.hpp>

// internal unnamed namespace

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

  // variables, internal

#if !defined(_MSC_VER) || (defined(_MSC_VER) && (_MSC_VER > 1800))
  constexpr
#endif
  unsigned const dflt[3] = { 5, 3, 2 };
  
  // functions, internal

} // namespace {

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

BOOST_AUTO_TEST_CASE(test_geometry_lattice_ctor)
{
  using ltype = geometry::lattice<glm::vec3, dflt[0], dflt[1], dflt[2]>;

  glm::vec3 const v(0,1,2);
  ltype const     l(v);
  
  BOOST_CHECK  (v == l.at(0,0,0));
}

BOOST_AUTO_TEST_CASE(test_geometry_lattice_print_on)
{
  using ltype = geometry::lattice<glm::vec3, 1, 2, 3>;

  ltype const l;
  
  BOOST_CHECK       (true);
  BOOST_TEST_MESSAGE(glm::io::precision(1) << glm::io::width(3) << l);
}

BOOST_AUTO_TEST_CASE(test_geometry_lattice_at)
{
  using ltype = geometry::lattice<glm::vec3, dflt[0], dflt[1], dflt[2]>;

  {
    ltype const l;
    
    BOOST_CHECK  (ltype::value_type() == l.at(0,0,0));
  }

  {
    glm::vec3 const v(1,-1,1);
    ltype           l;
    
    l.at(0,0,0) = v;
    
    BOOST_CHECK  (v == l.at(0,0,0));
  }

  {
    ltype l;
  
    BOOST_CHECK_THROW(l.at(dflt[0], dflt[1], dflt[2]), std::range_error);
  }

  {
    ltype const l;

    BOOST_CHECK_THROW(l.at(dflt[0], dflt[1], dflt[2]), std::range_error);
{'fraction_non_alphanumeric': 0.228168504791177, 'fraction_numerical': 0.021153498463207375, 'mean_word_length': 1.5634847080630214, 'pattern_counts': {'":': 0, '<': 31, '<?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': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5916761', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1560, 'n_words': 262}