This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
/
LazyMatrixProductTests.cc
77 lines (66 loc) · 2.51 KB
/
LazyMatrixProductTests.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Copyright (C) 2016 by the linalgwrap authors
//
// This file is part of linalgwrap.
//
// linalgwrap is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// linalgwrap is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with linalgwrap. If not, see <http://www.gnu.org/licenses/>.
//
#include "generators.hh"
#include "lazy_matrix_tests_state.hh"
#include "rapidcheck_utils.hh"
#include <catch.hpp>
#include <linalgwrap/LazyMatrixProduct.hh>
#include <rapidcheck.h>
namespace linalgwrap {
namespace tests {
using namespace rc;
TEST_CASE("LazyMatrixProduct", "[LazyMatrixProduct]") {
// Make sure that the program does not get aborted
AssertDbgEffect::set(ExceptionEffect::THROW);
// TODO Test swap function
// TODO Test constructors
typedef double scalar_type;
typedef SmallMatrix<scalar_type> stored_matrix_type;
typedef stored_matrix_type model_matrix_type;
SECTION("Random function test") {
auto random_test = [] {
model_matrix_type in(2, 3);
in(0, 0) = 3;
in(1, 1) = 2;
in(0, 1) = -1;
in(1, 0) = -4;
in(0, 2) = 1;
in(1, 2) = -1;
//
// The actual test
//
// The test library we use
typedef lazy_matrix_tests::StatefulTestingLibrary<
model_matrix_type, LazyMatrixProduct<stored_matrix_type>>
test_library;
// The commands we check
auto genCommands =
state::gen::execOneOf<typename test_library::op_MultiplyLazy,
typename test_library::op_UnaryMinus,
typename test_library::op_MultScalar,
typename test_library::op_DivideScalar>;
// Run the check:
test_library().run_check(in, genCommands, 0.25);
};
REQUIRE(rc::check("Random function test of LazyMatrixProduct.",
random_test));
} // Random function test
}
} // namespace tests
} // namescpace linalgwrap