<commit_before>//=======================================================================
// Copyright (c) 2014-2016 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#undef NDEBUG
#define CPP_UTILS_ASSERT_EXCEPTION

#include "etl/etl_light.hpp"
#include "catch.hpp"

TEST_CASE("assert/sizes/1", "[assert]") {
    etl::dyn_vector<double> a = {-1.0, 2.0, 5.0};
    etl::dyn_vector<double> b = {2.5, 3.0, 4.0, 1.0};

    REQUIRE_THROWS(a + b);
}

TEST_CASE("assert/dim/1", "[assert]") {
    etl::fast_matrix<double, 2, 3, 4> matrix;

    REQUIRE_NOTHROW(matrix(1, 1, 1));
    REQUIRE_THROWS(matrix(3, 2, 1));
    REQUIRE_THROWS(matrix(2, 2, 1));
    REQUIRE_THROWS(matrix(1, 5, 1));
    REQUIRE_THROWS(matrix(1, 1, 5));
    REQUIRE_THROWS(matrix(1, 1, 4));
    REQUIRE_THROWS(matrix(3, 3, 4));
}

TEST_CASE("assert/dim/2", "[assert]") {
    etl::fast_dyn_matrix<double, 2, 3, 4> matrix;

    REQUIRE_NOTHROW(matrix(1, 1, 1));
    REQUIRE_THROWS(matrix(3, 2, 1));
    REQUIRE_THROWS(matrix(2, 2, 1));
    REQUIRE_THROWS(matrix(1, 5, 1));
    REQUIRE_THROWS(matrix(1, 1, 5));
    REQUIRE_THROWS(matrix(1, 1, 4));
    REQUIRE_THROWS(matrix(3, 3, 4));
}

TEST_CASE("assert/dim/3", "[assert]") {
    etl::dyn_matrix<double, 3> matrix(2, 3, 4);

    REQUIRE_NOTHROW(matrix(1, 1, 1));
    REQUIRE_THROWS(matrix(3, 2, 1));
    REQUIRE_THROWS(matrix(2, 2, 1));
    REQUIRE_THROWS(matrix(1, 5, 1));
    REQUIRE_THROWS(matrix(1, 1, 5));
    REQUIRE_THROWS(matrix(1, 1, 4));
    REQUIRE_THROWS(matrix(3, 3, 4));
}

TEST_CASE("assert/dim/4", "[assert]") {
    etl::sparse_matrix<double> matrix(2, 3);

    REQUIRE_NOTHROW(matrix(1, 1));
    REQUIRE_THROWS(matrix(3, 2));
    REQUIRE_THROWS(matrix(2, 2));
    REQUIRE_THROWS(matrix(1, 5));
    REQUIRE_THROWS(matrix(3, 5));
}<commit_msg>Review assert test case<commit_after>//=======================================================================
// Copyright (c) 2014-2016 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#ifndef NDEBUG

#include "etl/etl_light.hpp"
#include "catch.hpp"

TEST_CASE("assert/nothrow/1", "[assert]") {
#ifdef CPP_UTILS_ASSERT_EXCEPTION
    REQUIRE(!etl::assert_nothrow);
#else
    REQUIRE(etl::assert_nothrow);
#endif
}

#ifdef CPP_UTILS_ASSERT_EXCEPTION
TEST_CASE("assert/sizes/1", "[assert]") {
    etl::dyn_vector<double> a = {-1.0, 2.0, 5.0};
    etl::dyn_vector<double> b = {2.5, 3.0, 4.0, 1.0};

    REQUIRE_THROWS(a + b);
}

TEST_CASE("assert/dim/1", "[assert]") {
    etl::fast_matrix<double, 2, 3, 4> matrix;

    REQUIRE_NOTHROW(matrix(1, 1, 1));
    REQUIRE_THROWS(matrix(3, 2, 1));
    REQUIRE_THROWS(matrix(2, 2, 1));
    REQUIRE_THROWS(matrix(1, 5, 1));
    REQUIRE_THROWS(matrix(1, 1, 5));
    REQUIRE_THROWS(matrix(1, 1, 4));
    REQUIRE_THROWS(matrix(3, 3, 4));
}

TEST_CASE("assert/dim/2", "[assert]") {
    etl::fast_dyn_matrix<double, 2, 3, 4> matrix;

    REQUIRE_NOTHROW(matrix(1, 1, 1));
    REQUIRE_THROWS(matrix(3, 2, 1));
    REQUIRE_THROWS(matrix(2, 2, 1));
    REQUIRE_THROWS(matrix(1, 5, 1));
    REQUIRE_THROWS(matrix(1, 1, 5));
    REQUIRE_THROWS(matrix(1, 1, 4));
    REQUIRE_THROWS(matrix(3, 3, 4));
}

TEST_CASE("assert/dim/3", "[assert]") {
    etl::dyn_matrix<double, 3> matrix(2, 3, 4);

    REQUIRE_NOTHROW(matrix(1, 1, 1));
    REQUIRE_THROWS(matrix(3, 2, 1));
    REQUIRE_THROWS(matrix(2, 2, 1));
    REQUIRE_THROWS(matrix(1, 5, 1));
    REQUIRE_THROWS(matrix(1, 1, 5));
    REQUIRE_THROWS(matrix(1, 1, 4));
    REQUIRE_THROWS(matrix(3, 3, 4));
}

TEST_CASE("assert/dim/4", "[assert]") {
    etl::sparse_matrix<double> matrix(2, 3);

    REQUIRE_NOTHROW(matrix(1, 1));
    REQUIRE_THROWS(matrix(3, 2));
    REQUIRE_THROWS(matrix(2, 2));
    REQUIRE_THROWS(matrix(1, 5));
    REQUIRE_THROWS(matrix(3, 5));
}
#endif

#endif
{'fraction_non_alphanumeric': 0.24876968503937008, 'fraction_numerical': 0.055364173228346455, 'mean_word_length': 4.661559888579387, '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': '6570578', 'n_tokens_mistral': 1925, 'n_tokens_neox': 1696, 'n_words': 299}