40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
#include <cxxtest/TestSuite.h>
|
|
|
|
#include "interlinknetworks.hh"
|
|
|
|
class InterlinkNetworks_test: public CxxTest::TestSuite
|
|
{
|
|
public:
|
|
|
|
void test_distance(void)
|
|
{
|
|
TrilaterationAlgorithm *algo = new InterlinkNetworks() ;
|
|
|
|
// Initialise algo->request
|
|
char mobile_gain = 3, mobile_power = 15 ;
|
|
Mobile mobile("", "", mobile_gain, mobile_power) ;
|
|
Request request(&mobile) ;
|
|
algo->compute(request) ; // yes, that's ugly
|
|
|
|
char ap_gain = 5, ap_power = 20, ap_channel = 1 ;
|
|
AccessPoint ap(Point3D(), "", "", ap_gain, ap_power, ap_channel) ;
|
|
|
|
std::vector<int> ss_list ;
|
|
ss_list.push_back(-42) ;
|
|
Measurement measurement(&ap, ss_list) ;
|
|
|
|
/* ** How to check ref_distance in Scilab? **
|
|
* C = 5 + 20 + 20 * log10(299792458 / 2412000000 / (4 * PI)) + 3
|
|
* L = -42
|
|
* ref_distance = 10^((C-L)/35)
|
|
*/
|
|
float ref_distance = 7.1519 ;
|
|
|
|
float computed_distance = algo->estimate_distance(measurement) ;
|
|
TS_ASSERT_DELTA(computed_distance, ref_distance, 0.0001) ;
|
|
|
|
delete algo ;
|
|
}
|
|
|
|
} ;
|