<commit_before>/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * This file is part of the libetonyek project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <sstream>

#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>

#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/io.hpp>

#include "IWORKTransformation.h"
#include "IWORKTypes.h"

#include "libetonyek_utils.h"

CPPUNIT_NS_BEGIN

template<>
struct assertion_traits<glm::dvec3>
{
  static bool equal(const glm::dvec3 &x, const glm::dvec3 &y)
  {
    return libetonyek::approxEqual(x, y);
  }

  static std::string toString(const glm::dvec3 &x)
  {
    std::ostringstream s;
    s << x;
    return s.str();
  }
};

template<>
struct assertion_traits<glm::dmat3>
{
  static bool equal(const glm::dmat3 &x, const glm::dmat3 &y)
  {
    return libetonyek::approxEqual(x, y);
  }

  static std::string toString(const glm::dmat3 &x)
  {
    std::ostringstream s;
    s << x;
    return s.str();
  }
};

CPPUNIT_NS_END

namespace test
{

using libetonyek::etonyek_half_pi;
using libetonyek::etonyek_pi;

namespace
{

glm::dmat3 wrap(const double width, const double height, const glm::dmat3 &tr)
{
  using namespace libetonyek::transformations;
  return center(width, height) * tr * origin(width, height);
}<commit_msg>implement own printing of glm types<commit_after>/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * This file is part of the libetonyek project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <iomanip>
#include <sstream>

#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>

#include "IWORKTransformation.h"
#include "IWORKTypes.h"

#include "libetonyek_utils.h"

namespace
{

void writeVec(std::ostream &os, double x, double y, double z, int w)
{
  os << '['
     << std::setw(w) << x << ',' << std::setw(w) << y << ',' << std::setw(w) << z
     << ']'
     ;
}

}

CPPUNIT_NS_BEGIN

template<>
struct assertion_traits<glm::dvec3>
{
  static bool equal(const glm::dvec3 &x, const glm::dvec3 &y)
  {
    return libetonyek::approxEqual(x, y);
  }

  static std::string toString(const glm::dvec3 &x)
  {
    std::ostringstream s;
    s << std::setfill(' ') << std::right << std::fixed << std::showpoint << std::setprecision(3);
    writeVec(s, x.x, x.y, x.z, 8);
    return s.str();
  }
};

template<>
struct assertion_traits<glm::dmat3>
{
  static bool equal(const glm::dmat3 &x, const glm::dmat3 &y)
  {
    return libetonyek::approxEqual(x, y);
  }

  static std::string toString(const glm::dmat3 &x)
  {
    std::ostringstream s;
    s << std::setfill(' ') << std::right << std::fixed << std::showpoint << std::setprecision(3);
    s << "\n[";
    writeVec(s, x[0][0], x[1][0], x[2][0], 8);
    s << "\n ";
    writeVec(s, x[0][1], x[1][1], x[2][1], 8);
    s << "\n ";
    writeVec(s, x[0][2], x[1][2], x[2][2], 8);
    s << ']';
    return s.str();
  }
};

CPPUNIT_NS_END

namespace test
{

using libetonyek::etonyek_half_pi;
using libetonyek::etonyek_pi;

namespace
{

glm::dmat3 wrap(const double width, const double height, const glm::dmat3 &tr)
{
  using namespace libetonyek::transformations;
  return center(width, height) * tr * origin(width, height);
}
{'fraction_non_alphanumeric': 0.16782439566546262, 'fraction_numerical': 0.015559877743817728, 'mean_word_length': 3.904632152588556, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 19, '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': '2121324', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1383, 'n_words': 347}