-
Notifications
You must be signed in to change notification settings - Fork 0
/
neuron_unittest.cpp
78 lines (67 loc) · 1.48 KB
/
neuron_unittest.cpp
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
78
#include "neuron.h"
#include "gtest/gtest.h"
namespace {
TEST(neuron, updateState_1) {
neuron* n = new neuron();
n->setCurrent(0.9);
for(int i = 0; i < 500; ++i) {
n->updateState(i);
}
EXPECT_EQ(0, n->getSpikes());
}
TEST(neuron, updateState_2) {
neuron* n = new neuron();
n->setCurrent(1.1);
for(int i = 0; i < 500; ++i) {
n->updateState(i);
}
EXPECT_EQ(1, n->getSpikes());
}
TEST(neuron, updateState_3) {
neuron* n = new neuron();
n->setCurrent(1);
n->updateState(1);
n->updateState(2);
EXPECT_EQ(false, n->updateState(3));
}
TEST(neuron, updateState_4) {
neuron* n = new neuron();
n->setCurrent(1000);
n->updateState(1);
n->updateState(2);
n->updateState(3);
EXPECT_EQ(true, n->isRefractoring());
}
TEST(neuron, updateRefractoring) {
neuron* n = new neuron();
n->setCurrent(1000);
for(int i=0; i < 22; ++i) {
n -> updateState(i);
}
EXPECT_EQ(false, n->isRefractoring());
}
TEST(neuron, targets) {
neuron* n = new neuron();
std::vector<neuron*> targets;
for(int i=0; i< 5; ++i) {
neuron* ni = new neuron();
n->addTarget(ni);
targets.push_back(ni);
}
EXPECT_EQ(targets, n->getTargets());
}
TEST(neuron, receive) {
neuron* n = new neuron();
n->receive(0, 21);
for(int i=0; i<16; ++i) {
n->updateState(i);
}
EXPECT_EQ(true, n->updateState(16));
}
TEST(neuron, receiveFromExt) {
neuron* n = new neuron();
n->receiveFromExt(21);
n->updateState(1);
EXPECT_EQ(true, n->updateState(2));
}
}