Skip to content

Commit c88591c

Browse files
committed
added test for invalid parameter
1 parent 600cab6 commit c88591c

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

neuromapp/nest/synapse/main.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ namespace nest
8484
const double x = vm["x"].as<double>();
8585
const double tau_rec = vm["tau_rec"].as<double>();
8686
const double tau_fac = vm["tau_fac"].as<double>();
87+
8788
try {
88-
tsodyks2 syn tsodyks2(delay, weight, U, u, x, tau_rec, tau_fac);
89+
tsodyks2 syn(delay, weight, U, u, x, tau_rec, tau_fac);
8990
}
90-
catch std::invalid_argument& e {
91+
catch (std::invalid_argument& e) {
9192
std::cout << "Error in model parameters: " << e.what() << std::endl;
93+
return mapp::MAPP_BAD_DATA;
9294
}
9395
}
9496
/* else if ( more models ) */
@@ -134,6 +136,7 @@ namespace nest
134136
double dt = vm["dt"].as<double>();
135137
int iterations = vm["iterations"].as<int>();
136138

139+
//will turn into ptr to base class if more synapse are implemented
137140
boost::scoped_ptr<tsodyks2> syn;
138141

139142
if (vm["model"].as<std::string>() == "tsodyks2") {
@@ -145,11 +148,16 @@ namespace nest
145148
const double tau_rec = vm["tau_rec"].as<double>();
146149
const double tau_fac = vm["tau_fac"].as<double>();
147150

148-
syn.reset(new tsodyks2(delay, weight, U, u, x, tau_rec, tau_fac));
151+
try {
152+
syn.reset(new tsodyks2(delay, weight, U, u, x, tau_rec, tau_fac));
153+
}
154+
catch (std::invalid_argument& e) {
155+
std::cout << "Error in model parameters: " << e.what() << std::endl;
156+
}
149157
}
150158
/* else if () .. further synapse models*/
151159
else {
152-
std::cerr << "synapse model implementation missing" << std::endl;
160+
std::cout << "Error: Synapse model implementation missing" << std::endl;
153161
}
154162

155163
//preallocate vector for results

test/nest/synapse.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,24 @@ BOOST_AUTO_TEST_CASE(nest_synapse_test)
4646
error = mapp::execute(command_v,nest::synapse_execute);
4747
BOOST_CHECK(error==mapp::MAPP_OK);
4848

49-
//trying out wrong model parameter
49+
//trying out wrong model
5050
command_v.clear();
5151
command_v.push_back("synapse_execute"); // dummy argument to be compliant with getopt
5252
command_v.push_back("--model");
5353
command_v.push_back("synnotthere"); // model does not exist
5454
error = mapp::execute(command_v,nest::synapse_execute);
5555
BOOST_CHECK(error==mapp::MAPP_BAD_DATA);
5656

57+
//trying out wrong model parameters
58+
command_v.clear();
59+
command_v.push_back("synapse_execute"); // dummy argument to be compliant with getopt
60+
command_v.push_back("--model");
61+
command_v.push_back("tsodyks2");
62+
command_v.push_back("--U");
63+
command_v.push_back("2.0"); // model does not exist
64+
error = mapp::execute(command_v,nest::synapse_execute);
65+
BOOST_CHECK(error==mapp::MAPP_BAD_DATA);
66+
5767
//trying out invalid dt
5868
command_v.clear();
5969
command_v.push_back("synapse_execute"); // dummy argument to be compliant with getopt

0 commit comments

Comments
 (0)