<commit_before>//
// Copyright (c) 2012 <NAME> <EMAIL>
// This file is part of minimath.
// Subject to the Lesser GNU Public License 
// - see < http://www.gnu.org/licenses/lgpl.html>
//

#ifndef TESTS_TRANSLATION3D_H__
#define TESTS_TRANSLATION3D_H__


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

#include "Math/Translation3D.h"
#include "Math/Point3D.h"

namespace
{
  using Math::Translation3D;
  using Math::PointXYZD;
}

class TestTranslation3D : public CppUnit::TestFixture {

  CPPUNIT_TEST_SUITE(TestTranslation3D);
  CPPUNIT_TEST(testInstantiation);
  CPPUNIT_TEST(testDefaultEquality);
  CPPUNIT_TEST(testCopyConstruction);
  CPPUNIT_TEST(testAssignment);
  CPPUNIT_TEST(testNullTranslation);
  CPPUNIT_TEST(testTranslatePoint);
  CPPUNIT_TEST_SUITE_END();

 protected:

  void testInstantiation()
  {
    Translation3D displ1, displ2;
  }

  void testDefaultEquality()
  {
    CPPUNIT_ASSERT(Translation3D() == Translation3D());
  }

  void testCopyConstruction()
  {
    Translation3D displ1;
    Translation3D displ2(displ1);
    CPPUNIT_ASSERT(displ1==displ2);
  }

  void testAssignment()
  {
    Translation3D displ1, displ2;
    displ2 = displ1;
    CPPUNIT_ASSERT(displ1==displ2);
  }

  void testNullTranslation() {
    PointXYZD p(11, 22, 33);
    CPPUNIT_ASSERT(PointXYZD(11,22,33) == Translation3D()*p);
  }

  void testTranslatePoint() {
    PointXYZD p(11, 22, 33);
    Translation3D t(PointXYZD(100, 200, 300));
    CPPUNIT_ASSERT(PointXYZD(111, 222, 333) == t*p);
  }

};<commit_msg>Add test for compound Translation3D transformations.<commit_after>//
// Copyright (c) 2012 <NAME> <EMAIL>
// This file is part of minimath.
// Subject to the Lesser GNU Public License 
// - see < http://www.gnu.org/licenses/lgpl.html>
//

#ifndef TESTS_TRANSLATION3D_H__
#define TESTS_TRANSLATION3D_H__

#include <vector>
#include <numeric>
#include <functional>

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

#include "Math/Translation3D.h"
#include "Math/Point3D.h"

namespace
{
  using Math::Translation3D;
  using Math::PointXYZD;
}

class TestTranslation3D : public CppUnit::TestFixture {

  CPPUNIT_TEST_SUITE(TestTranslation3D);
  CPPUNIT_TEST(testInstantiation);
  CPPUNIT_TEST(testDefaultEquality);
  CPPUNIT_TEST(testCopyConstruction);
  CPPUNIT_TEST(testAssignment);
  CPPUNIT_TEST(testNullTranslation);
  CPPUNIT_TEST(testTranslatePoint);
  CPPUNIT_TEST(testCompoundTranslation);
  CPPUNIT_TEST_SUITE_END();

 protected:

  void testInstantiation()
  {
    Translation3D displ1, displ2;
  }

  void testDefaultEquality()
  {
    CPPUNIT_ASSERT(Translation3D() == Translation3D());
  }

  void testCopyConstruction()
  {
    Translation3D displ1;
    Translation3D displ2(displ1);
    CPPUNIT_ASSERT(displ1==displ2);
  }

  void testAssignment()
  {
    Translation3D displ1, displ2;
    displ2 = displ1;
    CPPUNIT_ASSERT(displ1==displ2);
  }

  void testNullTranslation() {
    PointXYZD p(11, 22, 33);
    CPPUNIT_ASSERT(PointXYZD(11,22,33) == Translation3D()*p);
  }

  void testTranslatePoint() {
    for (int i = 0; i < 100; ++i)
    {
      PointXYZD p(11, 22, 33);
      Translation3D t1(PointXYZD(i, i, i));
      CPPUNIT_ASSERT(PointXYZD(11+i, 22+i, 33+i) == t1*p);
      Translation3D t2(PointXYZD(-i, -i, -i));
      CPPUNIT_ASSERT(PointXYZD(11-i, 22-i, 33-i) == t2*p);
    }
  }

  void testCompoundTranslation()
  {
    // make a vector of many translations
    std::vector<Translation3D> v;
    int sum = 0;
    for (int i = 0; i<10; ++i)
    {
      sum += i;
      v.push_back(Translation3D(PointXYZD(i,i,i)));
    }
    // multiply all the translations together
    Translation3D t = std::accumulate(v.begin(), v.end(),
                                      Translation3D(), 
                                      std::multiplies<Translation3D>());
    CPPUNIT_ASSERT(PointXYZD(sum, sum, sum) == t*PointXYZD());
  }

};
{'fraction_non_alphanumeric': 0.12633723892002038, 'fraction_numerical': 0.03795211411105451, 'mean_word_length': 3.854140914709518, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6789816', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1411, 'n_words': 258}