diff options
author | Michael Vogt <mvo@debian.org> | 2015-08-20 12:05:49 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2015-08-20 12:05:49 +0200 |
commit | f5c0ab925fdceb1bc0ef0e958cae7d0fafb28caf (patch) | |
tree | 959633a2debcd3572ff578558916243461a0e0f2 /test/libapt/srvrecs_test.cc | |
parent | defe3231c7bafc4d789219a3250be9ccfbc51914 (diff) | |
parent | c29dbdffcb6f67812f823f1f844b87320cf6b437 (diff) |
Merge remote-tracking branch 'mvo/feature/srv-records' into debian/experimental
Diffstat (limited to 'test/libapt/srvrecs_test.cc')
-rw-r--r-- | test/libapt/srvrecs_test.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/libapt/srvrecs_test.cc b/test/libapt/srvrecs_test.cc new file mode 100644 index 000000000..7e43cc757 --- /dev/null +++ b/test/libapt/srvrecs_test.cc @@ -0,0 +1,33 @@ +#include <config.h> + +#include <apt-pkg/srvrec.h> + +#include <string> +#include <iostream> + +#include <gtest/gtest.h> + +TEST(SrvRecTest, PopFromSrvRecs) +{ + // the PopFromSrvRecs() is using a random number so we must + // run it a bunch of times to ensure we are not fooled by randomness + std::set<std::string> selected; + for(int i=0;i<100;i++) + { + std::vector<SrvRec> Meep; + SrvRec foo = {target:"foo", priority: 20, weight: 0, port: 80}; + Meep.push_back(foo); + + SrvRec bar = {target:"bar", priority: 20, weight: 0, port: 80}; + Meep.push_back(bar); + + EXPECT_EQ(Meep.size(), 2); + SrvRec result = PopFromSrvRecs(Meep); + selected.insert(result.target); + // ensure that pop removed one element + EXPECT_EQ(Meep.size(), 1); + } + + // ensure that after enough runs we end up with both selected + EXPECT_EQ(selected.size(), 2); +} |