Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noraabiakar committed Oct 21, 2021
1 parent 7db8ece commit b26b881
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ set(test_mechanisms
test2_kin_diff
test3_kin_diff
test4_kin_compartment
test5_nonlinear_diff
test6_nonlinear_diff
test_ca
test_ca_read_valence
test_cl_valence
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mod/test4_kin_compartment.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ KINETIC state {
COMPARTMENT s1 {d e}

~ A + B <-> C ( x, y )
~ A + d <-> e ( z, w )
~ A + d <-> e ( z, w )
}
29 changes: 29 additions & 0 deletions test/unit/mod/test5_nonlinear_diff.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
NEURON {
SUFFIX test5_nonlinear_diff
}

STATE {
a b c
}

BREAKPOINT {
SOLVE state METHOD sparse
}

DERIVATIVE state {
LOCAL f0, f1, r0, r1
f0 = 2
r0 = 1
f1 = 3
r1 = 0

a' = -f0*a*b + r0*c
b' = -f0*a*b -r1*b + (r0+f1)*c
c' = f0*a*b +r1*b - (r0+f1)*c
}

INITIAL {
a = 0.2
b = 0.3
c = 0.5
}
19 changes: 19 additions & 0 deletions test/unit/mod/test6_nonlinear_diff.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
NEURON {
SUFFIX test6_nonlinear_diff
}

STATE {
p
}

BREAKPOINT {
SOLVE state METHOD sparse
}

DERIVATIVE state {
p' = sin(p)
}

INITIAL {
p = 1
}
28 changes: 28 additions & 0 deletions test/unit/test_kinetic_linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ TEST(mech_kinetic, kinetic_nonlinear) {

}

TEST(mech_kinetic, normal_nonlinear_0) {
std::vector<std::string> state_variables = {"a", "b", "c"};
std::vector<fvm_value_type> t0_values = {0.2, 0.3, 0.5};
std::vector<fvm_value_type> t1_values = {0.2078873133, 0.34222075, 0.45777925};
run_test<multicore::backend>("test5_nonlinear_diff", state_variables, t0_values, t1_values, 0.025);
}

TEST(mech_kinetic, normal_nonlinear_1) {
std::vector<std::string> state_variables = {"p"};
std::vector<fvm_value_type> t0_values = {1};
std::vector<fvm_value_type> t1_values = {1.0213199524};
run_test<multicore::backend>("test6_nonlinear_diff", state_variables, t0_values, t1_values, 0.025);
}

TEST(mech_kinetic, kinetic_nonlinear_scaled) {
std::vector<std::string> state_variables = {"A", "B", "C", "d", "e"};
std::vector<fvm_value_type> t0_values = {4.5, 6.6, 0.28, 2, 0};
Expand Down Expand Up @@ -192,6 +206,20 @@ TEST(mech_kinetic_gpu, kinetic_nonlinear) {
run_test<gpu::backend>("test3_kin_diff", state_variables, t0_values, t1_1_values, 0.025);
}

TEST(mech_kinetic_gpu, normal_nonlinear_0) {
std::vector<std::string> state_variables = {"a", "b", "c"};
std::vector<fvm_value_type> t0_values = {0.2, 0.3, 0.5};
std::vector<fvm_value_type> t1_values = {0.2078873133, 0.34222075, 0.45777925};
run_test<gpu::backend>("test5_nonlinear_diff", state_variables, t0_values, t1_values, 0.025);
}

TEST(mech_kinetic_gpu, normal_nonlinear_1) {
std::vector<std::string> state_variables = {"p"};
std::vector<fvm_value_type> t0_values = {1};
std::vector<fvm_value_type> t1_values = {1.0213199524};
run_test<gpu::backend>("test6_nonlinear_diff", state_variables, t0_values, t1_values, 0.025);
}

TEST(mech_kinetic_gpu, kinetic_nonlinear_scaled) {
std::vector<std::string> state_variables = {"A", "B", "C", "d", "e"};
std::vector<fvm_value_type> t0_values = {4.5, 6.6, 0.28, 2, 0};
Expand Down
4 changes: 4 additions & 0 deletions test/unit/unit_test_catalogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "mechanisms/test2_kin_diff.hpp"
#include "mechanisms/test3_kin_diff.hpp"
#include "mechanisms/test4_kin_compartment.hpp"
#include "mechanisms/test5_nonlinear_diff.hpp"
#include "mechanisms/test6_nonlinear_diff.hpp"
#include "mechanisms/test1_kin_steadystate.hpp"
#include "mechanisms/fixed_ica_current.hpp"
#include "mechanisms/point_ica_current.hpp"
Expand Down Expand Up @@ -82,6 +84,8 @@ mechanism_catalogue make_unit_test_catalogue(const mechanism_catalogue& from) {
ADD_MECH(cat, test1_kin_steadystate)
ADD_MECH(cat, test1_kin_compartment)
ADD_MECH(cat, test4_kin_compartment)
ADD_MECH(cat, test5_nonlinear_diff)
ADD_MECH(cat, test6_nonlinear_diff)
ADD_MECH(cat, fixed_ica_current)
ADD_MECH(cat, non_linear)
ADD_MECH(cat, point_ica_current)
Expand Down

0 comments on commit b26b881

Please sign in to comment.