fixing tests 3
This commit is contained in:
@@ -82,7 +82,9 @@ TEST_CASE("GetParamLoadedMatTest", "[CLIOptionTest]")
|
||||
// Create value.
|
||||
string filename = "hello.csv";
|
||||
arma::mat m(5, 5, arma::fill::ones);
|
||||
tuple<arma::mat, string> tuple = make_tuple(m, filename);
|
||||
typedef std::tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::mat, TupleType> tuple = make_tuple(m, testTuple);
|
||||
d.value = boost::any(tuple);
|
||||
// Mark it as already loaded.
|
||||
d.input = true;
|
||||
@@ -106,7 +108,9 @@ TEST_CASE("GetParamUnloadedMatTest", "[CLIOptionTest]")
|
||||
arma::mat test(5, 5, arma::fill::ones);
|
||||
data::Save("test.csv", test);
|
||||
arma::mat m;
|
||||
tuple<arma::mat, string> tuple = make_tuple(m, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::mat, TupleType> tuple = make_tuple(m, testTuple);
|
||||
d.value = boost::any(tuple);
|
||||
// Make sure it is not loaded yet.
|
||||
d.input = true;
|
||||
@@ -132,7 +136,9 @@ TEST_CASE("GetParamUmatTest", "[CLIOptionTest]")
|
||||
// Create value.
|
||||
string filename = "hello.csv";
|
||||
arma::Mat<size_t> m(5, 5, arma::fill::ones);
|
||||
tuple<arma::Mat<size_t>, string> tuple = make_tuple(m, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::Mat<size_t>, TupleType> tuple = make_tuple(m, testTuple);
|
||||
d.value = boost::any(tuple);
|
||||
// Mark it as already loaded.
|
||||
d.input = true;
|
||||
@@ -157,7 +163,9 @@ TEST_CASE("GetParamUnloadedUmatTest", "[CLIOptionTest]")
|
||||
arma::Mat<size_t> test(5, 5, arma::fill::ones);
|
||||
data::Save("test.csv", test);
|
||||
arma::Mat<size_t> m;
|
||||
tuple<arma::Mat<size_t>, string> tuple = make_tuple(m, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::Mat<size_t>, TupleType> tuple = make_tuple(m, testTuple);
|
||||
d.value = boost::any(tuple);
|
||||
// Make sure it is not loaded yet.
|
||||
d.input = true;
|
||||
@@ -199,8 +207,10 @@ TEST_CASE("GetParamDatasetInfoMatTest", "[CLIOptionTest]")
|
||||
data::DatasetInfo dd;
|
||||
arma::mat m;
|
||||
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<data::DatasetInfo, arma::mat> tuple1 = make_tuple(dd, m);
|
||||
tuple<decltype(tuple1), string> tuple2 = make_tuple(tuple1, filename);
|
||||
tuple<decltype(tuple1), TupleType> tuple2 = make_tuple(tuple1, testTuple);
|
||||
|
||||
d.value = boost::any(tuple2);
|
||||
// Make sure it is not loaded yet.
|
||||
@@ -274,7 +284,9 @@ TEST_CASE("RawParamMatTest", "[CLIOptionTest]")
|
||||
// Create value.
|
||||
string filename = "hello.csv";
|
||||
arma::mat m(5, 5, arma::fill::ones);
|
||||
tuple<arma::mat, string> tuple = make_tuple(m, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::mat, TupleType> tuple = make_tuple(m, testTuple);
|
||||
d.value = boost::any(tuple);
|
||||
d.input = true;
|
||||
d.loaded = false;
|
||||
@@ -322,9 +334,10 @@ TEST_CASE("GetRawParamDatasetInfoTest", "[CLIOptionTest]")
|
||||
// Create tuples.
|
||||
data::DatasetInfo dd(3);
|
||||
arma::mat m(3, 3, arma::fill::randu);
|
||||
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<data::DatasetInfo, arma::mat> tuple1 = make_tuple(dd, m);
|
||||
tuple<decltype(tuple1), string> tuple2 = make_tuple(tuple1, filename);
|
||||
tuple<decltype(tuple1), TupleType> tuple2 = make_tuple(tuple1, testTuple);
|
||||
|
||||
d.value = boost::any(tuple2);
|
||||
// Make sure it is not loaded yet.
|
||||
@@ -350,7 +363,9 @@ TEST_CASE("OutputParamMatTest", "[CLIOptionTest]")
|
||||
// Create value.
|
||||
string filename = "test.csv";
|
||||
arma::mat m(3, 3, arma::fill::randu);
|
||||
tuple<arma::mat, string> t = make_tuple(m, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::mat, TupleType> t = make_tuple(m, testTuple);
|
||||
|
||||
d.value = boost::any(t);
|
||||
d.input = false;
|
||||
@@ -376,7 +391,9 @@ TEST_CASE("OutputParamUmatTest", "[CLIOptionTest]")
|
||||
// Create value.
|
||||
string filename = "test.csv";
|
||||
arma::Mat<size_t> m(3, 3, arma::fill::randu);
|
||||
tuple<arma::Mat<size_t>, string> t = make_tuple(m, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::Mat<size_t>, TupleType> t = make_tuple(m, testTuple);
|
||||
|
||||
d.value = boost::any(t);
|
||||
d.input = false;
|
||||
@@ -467,7 +484,9 @@ TEST_CASE("SetParamMatrixTest", "[CLIOptionTest]")
|
||||
// Create initial value.
|
||||
string filename = "hello.csv";
|
||||
arma::mat m(5, 5, arma::fill::randu);
|
||||
d.value = boost::any(make_tuple(m, filename));
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
d.value = boost::any(make_tuple(m, testTuple));
|
||||
|
||||
// Get a new string.
|
||||
string newFilename = "new.csv";
|
||||
@@ -477,9 +496,9 @@ TEST_CASE("SetParamMatrixTest", "[CLIOptionTest]")
|
||||
(void*) NULL);
|
||||
|
||||
// Make sure the change went through.
|
||||
tuple<arma::mat, string>& t =
|
||||
*boost::any_cast<tuple<arma::mat, string>>(&d.value);
|
||||
REQUIRE(get<1>(t) == "new.csv");
|
||||
tuple<arma::mat, TupleType>& t =
|
||||
*boost::any_cast<tuple<arma::mat, TupleType>>(&d.value);
|
||||
REQUIRE(get<0>(get<1>(t)) == "new.csv");
|
||||
}
|
||||
|
||||
// Test that calling SetParam on a model sets the string correctly.
|
||||
@@ -517,8 +536,10 @@ TEST_CASE("SetParamDatasetInfoMatTest", "[CLIOptionTest]")
|
||||
string filename = "test.csv";
|
||||
arma::mat m(3, 3, arma::fill::randu);
|
||||
DatasetInfo di(3);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<DatasetInfo, arma::mat> t1 = make_tuple(di, m);
|
||||
tuple<tuple<DatasetInfo, arma::mat>, string> t2 = make_tuple(t1, filename);
|
||||
tuple<tuple<DatasetInfo, arma::mat>, TupleType> t2 = make_tuple(t1, testTuple);
|
||||
d.value = boost::any(t2);
|
||||
d.noTranspose = false;
|
||||
|
||||
@@ -530,10 +551,10 @@ TEST_CASE("SetParamDatasetInfoMatTest", "[CLIOptionTest]")
|
||||
(const void*) &a2, (void*) NULL);
|
||||
|
||||
// Check that the name is right.
|
||||
tuple<tuple<DatasetInfo, arma::mat>, string>& t3 =
|
||||
*boost::any_cast<tuple<tuple<DatasetInfo, arma::mat>, string>>(&d.value);
|
||||
tuple<tuple<DatasetInfo, arma::mat>, TupleType>& t3 =
|
||||
*boost::any_cast<tuple<tuple<DatasetInfo, arma::mat>, TupleType>>(&d.value);
|
||||
|
||||
REQUIRE(get<1>(t3) == "new_filename.csv");
|
||||
REQUIRE(get<0>(get<1>(t3)) == "new_filename.csv");
|
||||
}
|
||||
|
||||
// Test that GetAllocatedMemory() will properly return NULL for a non-model
|
||||
@@ -556,7 +577,9 @@ TEST_CASE("GetAllocatedMemoryNonModelTest", "[CLIOptionTest]")
|
||||
// Also test with a matrix type.
|
||||
arma::mat test(10, 10, arma::fill::ones);
|
||||
string filename = "test.csv";
|
||||
tuple<arma::mat, string> t = make_tuple(test, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::mat, TupleType> t = make_tuple(test, testTuple);
|
||||
d.value = boost::any(t);
|
||||
|
||||
result = (void*) 1;
|
||||
@@ -602,7 +625,9 @@ TEST_CASE("DeleteAllocatedMemoryNonModelTest", "[CLIOptionTest]")
|
||||
|
||||
arma::mat test(10, 10, arma::fill::ones);
|
||||
string filename = "test.csv";
|
||||
tuple<arma::mat, string> t = make_tuple(test, filename);
|
||||
typedef tuple<string, size_t, size_t> TupleType;
|
||||
TupleType testTuple{filename, 0, 0};
|
||||
tuple<arma::mat, TupleType> t = make_tuple(test, testTuple);
|
||||
d.value = boost::any(t);
|
||||
|
||||
DeleteAllocatedMemory<arma::mat>((util::ParamData&) d,
|
||||
|
||||
Reference in New Issue
Block a user