Permalink
Browse files

relaxed tets

  • Loading branch information...
janusheide committed Apr 4, 2018
1 parent 927fb61 commit 2625af95c44e9b060d1cf432ad919071041f3148
Showing with 42 additions and 46 deletions.
  1. +29 −35 test/src/test_spin_flipper.cpp
  2. +13 −11 test/src/test_spin_mirror.cpp
@@ -14,50 +14,44 @@
TEST(test_spin_flipper, basic)
{
bisp::spin_flipper<> sf;
uint8_t spin_bits;
EXPECT_EQ(boost::none, sf.rtt());
spin_bits = sf.outgoing();
sf.incomming(spin_bits);
EXPECT_EQ(1U, spin_bits);
EXPECT_EQ(1U, sf.outgoing());
sf.incomming(1U);
EXPECT_EQ(std::chrono::milliseconds(0), sf.rtt());
spin_bits = sf.outgoing();
sf.incomming(spin_bits);
EXPECT_EQ(2U, spin_bits);
EXPECT_EQ(2U, sf.outgoing());
sf.incomming(2U);
EXPECT_EQ(std::chrono::milliseconds(0), sf.rtt());
}
TEST(test_spin_sender, delay)
{
bisp::spin_flipper<> sf;
uint8_t spin_bits;
spin_bits = sf.outgoing();
std::this_thread::sleep_for(std::chrono::milliseconds(20));
sf.incomming(spin_bits);
EXPECT_EQ(1U, spin_bits);
EXPECT_EQ(std::chrono::milliseconds(20), sf.rtt());
spin_bits = sf.outgoing();
std::this_thread::sleep_for(std::chrono::milliseconds(20));
sf.incomming(spin_bits);
EXPECT_EQ(2U, spin_bits);
EXPECT_EQ(std::chrono::milliseconds(20), sf.rtt());
spin_bits = sf.outgoing();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
sf.incomming(spin_bits);
EXPECT_EQ(3U, spin_bits);
EXPECT_EQ(std::chrono::milliseconds(50), sf.rtt());
spin_bits = sf.outgoing();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
sf.incomming(spin_bits);
EXPECT_EQ(0U, spin_bits);
EXPECT_EQ(std::chrono::milliseconds(10), sf.rtt());
EXPECT_EQ(1U, sf.outgoing());
std::this_thread::sleep_for(std::chrono::milliseconds(200));
sf.incomming(1U);
EXPECT_LE(std::chrono::milliseconds(200), sf.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sf.rtt());
EXPECT_EQ(2U, sf.outgoing());
std::this_thread::sleep_for(std::chrono::milliseconds(200));
sf.incomming(2U);
EXPECT_LE(std::chrono::milliseconds(200), sf.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sf.rtt());
EXPECT_EQ(3U, sf.outgoing());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
sf.incomming(3U);
EXPECT_LE(std::chrono::milliseconds(100), sf.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sf.rtt());
EXPECT_EQ(0U, sf.outgoing());
std::this_thread::sleep_for(std::chrono::milliseconds(110));
sf.incomming(0U);
EXPECT_LE(std::chrono::milliseconds(110), sf.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sf.rtt());
EXPECT_EQ(1U, sf.outgoing());
}
@@ -14,7 +14,6 @@
TEST(test_spin_mirror, basic)
{
bisp::spin_mirror<> sm;
EXPECT_EQ(boost::none, sm.rtt());
sm.incomming(1U);
@@ -34,30 +33,33 @@ TEST(test_spin_receiver, delay)
EXPECT_EQ(boost::none, sm.rtt());
EXPECT_EQ(2U, sm.outgoing());
std::this_thread::sleep_for(std::chrono::milliseconds(20));
std::this_thread::sleep_for(std::chrono::milliseconds(200));
sm.incomming(3U);
EXPECT_EQ(3U, sm.outgoing());
EXPECT_EQ(std::chrono::milliseconds(20), sm.rtt());
EXPECT_LE(std::chrono::milliseconds(200), sm.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sm.rtt());
std::this_thread::sleep_for(std::chrono::milliseconds(17));
std::this_thread::sleep_for(std::chrono::milliseconds(170));
sm.incomming(0U);
EXPECT_EQ(0U, sm.outgoing());
EXPECT_EQ(std::chrono::milliseconds(17), sm.rtt());
EXPECT_LE(std::chrono::milliseconds(170), sm.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sm.rtt());
std::this_thread::sleep_for(std::chrono::milliseconds(42));
std::this_thread::sleep_for(std::chrono::milliseconds(120));
sm.incomming(1U);
EXPECT_EQ(1U, sm.outgoing());
EXPECT_EQ(std::chrono::milliseconds(42), sm.rtt());
EXPECT_LE(std::chrono::milliseconds(120), sm.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sm.rtt());
//invalid spin do nothing
sm.incomming(3U);
EXPECT_EQ(1U, sm.outgoing());
EXPECT_EQ(std::chrono::milliseconds(42), sm.rtt());
EXPECT_LE(std::chrono::milliseconds(120), sm.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sm.rtt());
//invalid spin do nothing
sm.incomming(0U);
EXPECT_EQ(1U, sm.outgoing());
EXPECT_EQ(std::chrono::milliseconds(42), sm.rtt());
EXPECT_LE(std::chrono::milliseconds(120), sm.rtt());
EXPECT_GE(std::chrono::milliseconds(1000), sm.rtt());
}

0 comments on commit 2625af9

Please sign in to comment.