<commit_before>// Catch
#include <catch.hpp>
#include "catchExtension.hpp"

// Mantella
#include <mantella>

SCENARIO("verify", "[assert][verify]") {
  GIVEN("An expression and a error message") {
    const std::string& errorMessage = "Some message ...";
    CAPTURE(errorMessage);

    WHEN("The expression is false") {
      const bool expression = false;
      CAPTURE(expression);

      THEN("Throw a std::logic_error") {
        CHECK_THROWS_AS(mant::verify(expression, errorMessage), std::logic_error);
      }
    }

    WHEN("The expression is true") {
      const bool expression = true;
      CAPTURE(expression);

      THEN("Throw no exception") {
        CHECK_NOTHROW(mant::verify(expression, errorMessage));
      }
    }
  }
}

SCENARIO("isRotationMatrix", "[assert][isRotationMatrix]") {
  GIVEN("A matrix") {
    WHEN("The matrix is orthogonal with determinant 1 or -1 (a rotation matrix)") {
      const arma::uword numberOfDimensions = discreteRandomNumber();
      CAPTURE(numberOfDimensions);

      arma::Mat<double> matrix = mant::randomRotationMatrix(numberOfDimensions);
      CAPTURE(matrix);

      THEN("Return true") {
        CHECK(mant::isRotationMatrix(matrix) == true);
        // Inverts the determinant's sign
        matrix.swap_cols(0, 1);
        CHECK(mant::isRotationMatrix(matrix) == true);
      }
    }

    WHEN("The matrix is not square") {
      const arma::uword numberOfDimensions = discreteRandomNumber();
      CAPTURE(numberOfDimensions);

      const arma::Mat<double>& matrix = arma::randu<arma::Mat<double>>(numberOfDimensions, 1 + numberOfDimensions);
      CAPTURE(matrix);

      THEN("Return false") {
        CHECK(mant::isRotationMatrix(matrix) == false);
      }
    }

    WHEN("The matrix's inverse is not equal to its transpose") {
      // We need at least 2 rows and columns for this to work.
      const arma::uword numberOfDimensions = 1 + discreteRandomNumber();
      CAPTURE(numberOfDimensions);

      arma::Mat<double> matrix = mant::randomRotationMatrix(numberOfDimensions);<commit_msg>fix: The isRotationMatrix test needs at least a two dimensional matrix to invert the determinant's sign<commit_after>// Catch
#include <catch.hpp>
#include "catchExtension.hpp"

// Mantella
#include <mantella>

SCENARIO("verify", "[assert][verify]") {
  GIVEN("An expression and a error message") {
    const std::string& errorMessage = "Some message ...";
    CAPTURE(errorMessage);

    WHEN("The expression is false") {
      const bool expression = false;
      CAPTURE(expression);

      THEN("Throw a std::logic_error") {
        CHECK_THROWS_AS(mant::verify(expression, errorMessage), std::logic_error);
      }
    }

    WHEN("The expression is true") {
      const bool expression = true;
      CAPTURE(expression);

      THEN("Throw no exception") {
        CHECK_NOTHROW(mant::verify(expression, errorMessage));
      }
    }
  }
}

SCENARIO("isRotationMatrix", "[assert][isRotationMatrix]") {
  GIVEN("A matrix") {
    WHEN("The matrix is orthogonal with determinant 1 or -1 (a rotation matrix)") {
      const arma::uword numberOfDimensions = 1 + discreteRandomNumber();
      CAPTURE(numberOfDimensions);

      arma::Mat<double> matrix = mant::randomRotationMatrix(numberOfDimensions);
      CAPTURE(matrix);

      THEN("Return true") {
        CHECK(mant::isRotationMatrix(matrix) == true);
        // Inverts the determinant's sign
        matrix.swap_cols(0, 1);
        CHECK(mant::isRotationMatrix(matrix) == true);
      }
    }

    WHEN("The matrix is not square") {
      const arma::uword numberOfDimensions = discreteRandomNumber();
      CAPTURE(numberOfDimensions);

      const arma::Mat<double>& matrix = arma::randu<arma::Mat<double>>(numberOfDimensions, 1 + numberOfDimensions);
      CAPTURE(matrix);

      THEN("Return false") {
        CHECK(mant::isRotationMatrix(matrix) == false);
      }
    }

    WHEN("The matrix's inverse is not equal to its transpose") {
      // We need at least 2 rows and columns for this to work.
      const arma::uword numberOfDimensions = 1 + discreteRandomNumber();
      CAPTURE(numberOfDimensions);

      arma::Mat<double> matrix = mant::randomRotationMatrix(numberOfDimensions);
{'fraction_non_alphanumeric': 0.12683736367946893, 'fraction_numerical': 0.0035561877667140826, 'mean_word_length': 3.497867803837953, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6232182', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1233, 'n_words': 295}