|
Revision 456, 1.0 kB
(checked in by vbarta, 16 years ago)
|
|
custom test location for harness tests (extended UnitTest?++), configurable tolerance - all tests pass (most of the time)
|
| Line | |
|---|
| 1 | #include "mat_checks.h" |
|---|
| 2 | |
|---|
| 3 | namespace UnitTest |
|---|
| 4 | { |
|---|
| 5 | |
|---|
| 6 | bool AreClose(const itpp::vec &expected, const itpp::vec &actual, |
|---|
| 7 | double tolerance) { |
|---|
| 8 | if (expected.length() != actual.length()) { |
|---|
| 9 | return false; |
|---|
| 10 | } |
|---|
| 11 | |
|---|
| 12 | for (int i = 0; i < expected.length(); ++i) { |
|---|
| 13 | if (!AreClose(expected(i), actual(i), tolerance)) { |
|---|
| 14 | return false; |
|---|
| 15 | } |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | return true; |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | bool AreClose(const itpp::mat &expected, const itpp::mat &actual, double tolerance) { |
|---|
| 22 | if ((expected.rows() != actual.rows()) || |
|---|
| 23 | (expected.cols() != actual.cols())) { |
|---|
| 24 | return false; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | for (int i = 0; i < expected.rows(); ++i) { |
|---|
| 28 | for (int j = 0; j < expected.cols(); ++j) { |
|---|
| 29 | if (!AreClose(expected(i, j), actual(i, j), tolerance)) { |
|---|
| 30 | return false; |
|---|
| 31 | } |
|---|
| 32 | } |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | return true; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | const char *CurrentContext::config_name = "???"; |
|---|
| 41 | |
|---|
| 42 | int CurrentContext::index = -1; |
|---|
| 43 | |
|---|
| 44 | CurrentContext::CurrentContext(const char *name, int idx) |
|---|
| 45 | { |
|---|
| 46 | config_name = name; |
|---|
| 47 | index = idx; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | CurrentContext::~CurrentContext() |
|---|
| 51 | { |
|---|
| 52 | config_name = "???"; |
|---|
| 53 | index = -1; |
|---|
| 54 | } |
|---|