]> git.saurik.com Git - apt.git/blob - test/libapt/srvrecs_test.cc
use unusable-for-security hashes for integrity checks
[apt.git] / test / libapt / srvrecs_test.cc
1 #include <config.h>
2
3 #include <apt-pkg/srvrec.h>
4
5 #include <string>
6 #include <iostream>
7
8 #include <gtest/gtest.h>
9
10 TEST(SrvRecTest, PopFromSrvRecs)
11 {
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++)
16 {
17 std::vector<SrvRec> Meep;
18 SrvRec foo = {target:"foo", priority: 20, weight: 0, port: 80};
19 Meep.push_back(foo);
20
21 SrvRec bar = {target:"bar", priority: 20, weight: 0, port: 80};
22 Meep.push_back(bar);
23
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);
29 }
30
31 // ensure that after enough runs we end up with both selected
32 EXPECT_EQ(selected.size(), 2);
33 }