/usr/include/ept/popcon/popcon.test.h is in libept-dev 1.0.12.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | // -*- mode: c++; tab-width: 4; indent-tabs-mode: t -*-
/*
* popcon test
*
* Copyright (C) 2007 Enrico Zini <enrico@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ept/popcon/popcon.h>
#include <ept/popcon/maint/path.h>
#include <ept/apt/apt.h>
#include <set>
#include <ept/test.h>
using namespace std;
using namespace ept;
using namespace ept::popcon;
using namespace ept::apt;
struct TestPopcon
{
popcon::Path::OverridePopconSourceDir odsd;
popcon::Path::OverridePopconIndexDir odid;
popcon::Path::OverridePopconUserSourceDir odusd;
popcon::Path::OverridePopconUserIndexDir oduid;
Apt apt;
Popcon popcon;
TestPopcon()
: odsd( TEST_ENV_DIR "popcon" ),
odid( TEST_ENV_DIR "popcon" ),
odusd( TEST_ENV_DIR "popcon" ),
oduid( TEST_ENV_DIR "popcon" )
{}
Test basicAccess()
{
assert_eq(popcon.submissions(), 52024);
assert(popcon.size() > 0);
assert(popcon.score(0) > 0);
assert(!popcon.name(0).empty());
}
// Check that every valid index is accessible
Test accessibility()
{
for (size_t i = 0; i < popcon.size(); ++i)
{
//cerr << popcon.name(i) << " " << popcon.score(i) << endl;
assert(popcon.score(i) > 0);
}
}
// Check that we can get a score for every package
Test haveScores()
{
int has = 0;
for (Apt::iterator i = apt.begin(); i != apt.end(); ++i)
{
float score = popcon.score(*i);
if (score > 0)
++has;
}
// At least 1000 packages should have a score
assert(has > 1000);
}
// Check that scores are meaningful
Test validScores()
{
assert(popcon["apt"] > popcon["libapt-pkg-dev"]);
}
// If there is no data, Popcon should work as if all scores were 0
Test fallbackValues()
{
popcon::Path::OverridePopconSourceDir odsd("./empty");
popcon::Path::OverridePopconIndexDir odid("./empty");
popcon::Path::OverridePopconUserSourceDir odusd("./empty");
popcon::Path::OverridePopconUserIndexDir oduid("./empty");
Popcon empty;
assert_eq(empty.timestamp(), 0);
assert(!empty.hasData());
assert_eq(empty.submissions(), 0);
assert(empty.size() == 0);
assert(empty.score("apt") == 0.0);
}
};
// vim:set ts=4 sw=4:
|