1 : // -*- C++ -*-
2 : #include <ept/core/apt.h>
3 :
4 : #include <ept/test.h>
5 :
6 : using namespace ept::core;
7 :
8 : struct TestAptRecord : AptTestEnvironment
9 6 : {
10 : record::Source recs;
11 : ept::Token t;
12 :
13 6 : TestAptRecord() : recs( db ) {
14 6 : t._id = "sp";
15 6 : }
16 :
17 1 : Test checkLookup() {
18 1 : recs.get< record::Record >( t );
19 1 : }
20 :
21 1 : Test checkLookupValue() {
22 1 : assert_eq( recs.get< record::Name >( t ), t.package() );
23 : assert_eq( recs.get< record::Maintainer >( t ),
24 2 : "Neil Roeth <neil@debian.org>" );
25 1 : }
26 :
27 1 : Test checkLookupNumeric() {
28 : assert_eq( recs.get< record::InstalledSize >( t ),
29 1 : 600 );
30 1 : }
31 :
32 1 : Test checkShortDescription() {
33 : assert_eq( recs.get< record::ShortDescription >( t ),
34 1 : "James Clark's SGML parsing tools" );
35 1 : }
36 :
37 : template< typename List >
38 1 : void checkRecordNameList( List l ) {
39 437 : while ( !l.empty() ) {
40 435 : assert_eq( l.property(), l.token().package() );
41 435 : l = l.tail();
42 : }
43 1 : }
44 :
45 1 : Test checkList() {
46 : // there are 435 valid records in the list file
47 : assert_eq( list::count( recs.list<
48 1 : record::Name >() ), 435 );
49 1 : checkRecordNameList( recs.list< record::Name >() );
50 1 : }
51 :
52 1 : Test nonexistent() {
53 : assert_eq( recs.get< record::ShortDescription >(
54 1 : ept::Token( "nonexistent-package" ) ), "" );
55 1 : }
56 : };
|