Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <ept/popcon/local.h>
00023 #include <ept/popcon/popcon.h>
00024 #include <ept/popcon/maint/path.h>
00025
00026 #include <ept/test.h>
00027
00028 using namespace std;
00029 using namespace ept;
00030 using namespace ept::popcon;
00031
00032 struct TestPopconLocal
00033 {
00034 Path::OverridePopconSourceDir odsd;
00035 Path::OverridePopconIndexDir odid;
00036 Path::OverridePopconUserSourceDir odusd;
00037 Path::OverridePopconUserIndexDir oduid;
00038
00039 Popcon popcon;
00040 Local local;
00041
00042 TestPopconLocal()
00043 : odsd( TEST_ENV_DIR "popcon" ),
00044 odid( TEST_ENV_DIR "popcon" ),
00045 odusd( TEST_ENV_DIR "popcon" ),
00046 oduid( TEST_ENV_DIR "popcon" ),
00047 local( TEST_ENV_DIR "popcon/popularity-contest" )
00048 {}
00049
00050
00051 Test basicAccess()
00052 {
00053 assert(local.score("apt") > 0);
00054 assert(local.tfidf(popcon, "apt") > 0);
00055 }
00056
00057 #if 0 // mornfall: apparently left out by enrico, leaving as it is
00058
00059 template<> template<>
00060 void to::test< 2 >()
00061 {
00062 for (size_t i = 0; i < popcon.size(); ++i)
00063 {
00064
00065 assert(popcon.score(i) > 0);
00066 }
00067 }
00068
00069
00070 template<> template<>
00071 void to::test< 3 >()
00072 {
00073 int has = 0;
00074 for (Apt::iterator i = apt.begin(); i != apt.end(); ++i)
00075 {
00076 float score = popcon.score(*i);
00077 if (score > 0)
00078 ++has;
00079 }
00080
00081 assert(has > 1000);
00082 }
00083
00084
00085 template<> template<>
00086 void to::test< 4 >()
00087 {
00088 assert(popcon["apt"] > popcon["libapt-pkg-dev"]);
00089 }
00090
00091
00092 template<> template<>
00093 void to::test<5>()
00094 {
00095 Path::OverridePopconSourceDir odsd("./empty");
00096 Path::OverridePopconIndexDir odid("./empty");
00097 Path::OverridePopconUserSourceDir odusd("./empty");
00098 Path::OverridePopconUserIndexDir oduid("./empty");
00099 Popcon empty;
00100
00101 assert_eq(empty.timestamp(), 0);
00102 assert(!empty.hasData());
00103
00104 assert(empty.size() == 0);
00105 assert(empty.score("apt") == 0.0);
00106 }
00107 #endif
00108
00109 };
00110
00111