|
1 #include <dtn-config.h> |
|
2 #include <oasys/util/UnitTest.h> |
|
3 #include <sys/types.h> |
|
4 #include <oasys/util/ScratchBuffer.h> |
|
5 #include <oasys/util/StringBuffer.h> |
|
6 #include <oasys/debug/Log.h> |
|
7 |
|
8 #include "prophet/BundleImpl.h" |
|
9 #include "prophet/Stats.h" |
|
10 |
|
11 using namespace oasys; |
|
12 |
|
13 |
|
14 DECLARE_TEST(Stats) { |
|
15 // dest_id, cts, seq, ets, size, num_fwd |
|
16 prophet::BundleImpl m("dtn://test-a",0xfe, 1, 60, 1024, 0); |
|
17 prophet::BundleImpl n("dtn://test-b",0xff, 2, 60, 512, 1); |
|
18 prophet::Stats s; |
|
19 |
|
20 CHECK(s.get_p_max(&n) == s.get_p_max(&m)); |
|
21 CHECK(s.get_mopr(&n) == s.get_mopr(&n)); |
|
22 CHECK(s.get_lmopr(&m) == s.get_lmopr(&n)); |
|
23 s.update_stats(&m,0.75); |
|
24 CHECK(s.get_p_max(&m) > s.get_p_max(&n)); |
|
25 CHECK(s.get_mopr(&m) > s.get_mopr(&n)); |
|
26 CHECK(s.get_lmopr(&m) > s.get_lmopr(&n)); |
|
27 s.drop_bundle(&m); |
|
28 CHECK_EQUAL(s.dropped(), 1); |
|
29 CHECK(s.get_p_max(&n) == s.get_p_max(&m)); |
|
30 CHECK(s.get_mopr(&n) == s.get_mopr(&n)); |
|
31 CHECK(s.get_lmopr(&m) == s.get_lmopr(&n)); |
|
32 |
|
33 return UNIT_TEST_PASSED; |
|
34 } |
|
35 |
|
36 DECLARE_TESTER(ProphetStatsTest) { |
|
37 ADD_TEST(Stats); |
|
38 } |
|
39 |
|
40 DECLARE_TEST_FILE(ProphetStatsTest, "prophet stats test"); |