/** @file test_suite.cpp
 *
 *  @author Cory Alexander Balaton (coryab)
 *  @author Janita Ovidie Sandtrøen Willumsen (janitaws)
 *
 *  @version 1.0
 *
 *  @brief Sweep over different temperatures and generate data.
 *
 *  @bug No known bugs
 * */
#include "IsingModel.hpp"
#include "testlib.hpp"

/** @brief Test class for the Ising model
 * */
class IsingModelTest {
public:
    /** @brief Test That initializing works as intended.
     * */
    void test_init_functions()
    {
        IsingModel test;
        test.L = 3;
        test.T = 1.;

        // Test that initializing the lattice only yields 1s and -1s.
        test.initialize_lattice();
        std::function<bool(int)> f = [](int x) { return x == 1 || x == -1; };
        ASSERT(testlib::assert_each(f, test.lattice),
               "Test lattice initialization.");

        test.initialize_neighbors();
        arma::Mat<uint> neighbor_matrix("2, 1 ; 0, 2 ; 1, 0");
        ASSERT(testlib::is_equal(neighbor_matrix, test.neighbors),
               "Test neighbor matrix.");

        // Fill the lattice with 1s to be able to test the next functions.
        test.lattice.fill(1);

        // Test the initial magnetization.
        test.initialize_magnetization();
        ASSERT(std::abs(test.M - 9.) < 1e-8, "Test intial magnetization");

        // Test that the initial energy is correct
        test.initialize_energy();
        ASSERT(std::abs(test.E - (-18)) < 1e-8, "Test initial energy.");
    }
};

/** @brief The main function.*/
int main()
{
    IsingModelTest test;

    test.test_init_functions();
}
