]>
git.saurik.com Git - apt.git/blob - test/libapt/srvrecs_test.cc
3 #include <apt-pkg/srvrec.h>
8 #include <gtest/gtest.h>
10 TEST(SrvRecTest
, PopFromSrvRecs
)
12 // the PopFromSrvRecs() is using a random number so we must
13 // run it a bunch of times to ensure we are not fooled by randomness
14 std::set
<std::string
> selected
;
15 for(int i
=0;i
<100;i
++)
17 std::vector
<SrvRec
> Meep
;
18 SrvRec foo
= {target
:"foo", priority
: 20, weight
: 0, port
: 80};
21 SrvRec bar
= {target
:"bar", priority
: 20, weight
: 0, port
: 80};
24 EXPECT_EQ(Meep
.size(), 2);
25 SrvRec result
= PopFromSrvRecs(Meep
);
26 selected
.insert(result
.target
);
27 // ensure that pop removed one element
28 EXPECT_EQ(Meep
.size(), 1);
31 // ensure that after enough runs we end up with both selected
32 EXPECT_EQ(selected
.size(), 2);