File: HistoryLogReader_test.cc

package info (click to toggle)
libzypp 17.38.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 27,716 kB
  • sloc: cpp: 132,661; xml: 2,587; sh: 518; python: 266; makefile: 27
file content (40 lines) | stat: -rw-r--r-- 1,773 bytes parent folder | download | duplicates (3)
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
#include <tests/lib/TestSetup.h>
#include <zypp/parser/HistoryLogReader.h>
#include <zypp-core/parser/ParseException>

using namespace zypp;

BOOST_AUTO_TEST_CASE(basic)
{
  std::vector<HistoryLogData::Ptr> history;
  parser::HistoryLogReader parser( TESTS_SRC_DIR "/parser/HistoryLogReader_test.dat",
                                   parser::HistoryLogReader::Options(),
    [&history]( HistoryLogData::Ptr ptr )->bool {
      history.push_back( ptr );
      return true;
    } );

  BOOST_CHECK_EQUAL( parser.ignoreInvalidItems(), false );
  BOOST_CHECK_THROW( parser.readAll(), parser::ParseException );

  parser.setIgnoreInvalidItems( true );
  BOOST_CHECK_EQUAL( parser.ignoreInvalidItems(), true );

  history.clear();
  parser.readAll();

  BOOST_CHECK_EQUAL( history.size(), 9 );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogDataRepoAdd>	( history[0] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogDataInstall>	( history[1] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogDataInstall>	( history[2] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogDataRemove>	( history[3] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogDataRepoRemove>	( history[4] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogDataRemove>	( history[5] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogData>		( history[6] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogDataStampCommand>	( history[7] ) );
  BOOST_CHECK( dynamic_pointer_cast<HistoryLogPatchStateChange>	( history[8] ) );

  BOOST_CHECK_EQUAL( (*history[1])[HistoryLogDataInstall::USERDATA_INDEX], "trans|ID" ); // properly (un)escaped?
  HistoryLogDataInstall::Ptr p = dynamic_pointer_cast<HistoryLogDataInstall>( history[1] );
  BOOST_CHECK_EQUAL( p->userdata(), "trans|ID" ); // properly (un)escaped?
}