MCPcopy Create free account
hub / github.com/davisking/dlib / dotest1

Function dotest1

dlib/test/bsp.cpp:139–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137
138
139 void dotest1()
140 {
141 dlog << LINFO << "start dotest1()";
142 print_spinner();
143 bool error_occurred = false;
144 {
145 thread_function t1(callfunct(sum_array_other, 12345, error_occurred));
146 thread_function t2(callfunct(sum_array_other, 12346, error_occurred));
147 thread_function t3(callfunct(sum_array_other, 12347, error_occurred));
148 std::vector<int> v;
149 int true_value = 0;
150 for (int i = 0; i < 10; ++i)
151 {
152 v.push_back(i);
153 true_value += i;
154 }
155
156 // wait a little bit for the threads to start up
157 dlib::sleep(200);
158
159 try
160 {
161 int result;
162 std::vector<network_address> hosts;
163 hosts.push_back("127.0.0.1:12345");
164 hosts.push_back("localhost:12346");
165 hosts.push_back("127.0.0.1:12347");
166 bsp_connect(hosts, sum_array_driver, dlib::ref(v), dlib::ref(result));
167
168 dlog << LINFO << "result: "<< result;
169 dlog << LINFO << "should be: "<< 3*true_value;
170 DLIB_TEST(result == 3*true_value);
171 }
172 catch (std::exception& e)
173 {
174 dlog << LERROR << "error during bsp_context: " << e.what();
175 DLIB_TEST(false);
176 }
177 }
178 DLIB_TEST(error_occurred == false);
179 }
180
181// ----------------------------------------------------------------------------------------
182

Callers 1

perform_testMethod · 0.70

Calls 7

print_spinnerFunction · 0.85
callfunctFunction · 0.85
bsp_connectFunction · 0.85
refFunction · 0.85
sleepFunction · 0.50
push_backMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected