Changeset 309 for trunk


Ignore:
Timestamp:
May 12, 2007, 3:26:38 PM (14 years ago)
Author:
Peter Johansson
Message:

added test for Trac class. fixes #189

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Trac.cc

    r308 r309  
    9696      return false;
    9797    const std::string::const_iterator first_orig(first);
    98     if (match(first, last, Str("changeset:")).empty()){
     98    if (match(first, last, std::string("changeset:")).empty()){
    9999      first = first_orig;
    100100      return false;
     
    118118
    119119    const std::string::const_iterator first_orig(first);
    120     if (match(first, last, Str("comment:ticket:")).empty()){
     120    if (match(first, last, std::string("comment:ticket:")).empty()){
    121121      first = first_orig;
    122122      return false;
     
    153153                  const std::string::const_iterator& last)
    154154  {
     155    if (diff3(first, last))
     156      return true;
    155157    if (diff1(first, last))
    156       return true;
    157     if (diff3(first, last))
    158158      return true;
    159159    if (diff2(first, last))
     
    170170
    171171    const std::string::const_iterator first_orig(first);
    172     if (match(first, last, Str("diff:")).empty()){
     172    if (match(first, last, std::string("diff:")).empty()){
    173173      first = first_orig;
    174174      return false;
     
    198198      href = std::string(Configuration::instance().trac_root()+
    199199                         "changeset?new="+new_rev+"&new_path="+node+"&old="+
    200                          old_rev+"&oldpath="+node);
     200                         old_rev+"&old_path="+node);
    201201    hs_.stream() << anchor(href, std::string(first_orig, first));
    202202    return true;
     
    211211
    212212    const std::string::const_iterator first_orig(first);
    213     if (match(first, last, Str("diff:")).empty()){
     213    if (match(first, last, std::string("diff:")).empty()){
    214214      first = first_orig;
    215215      return false;
     
    241241
    242242    const std::string::const_iterator first_orig(first);
    243     if (match(first, last, Str("diff:")).empty()){
     243    if (match(first, last, std::string("diff:")).empty()){
    244244      first = first_orig;
    245245      return false;
     
    252252    ++first;
    253253    std::string old_rev(match(first, last, AlNum()));
    254     if (!match_begin(first, first+1, std::string("//"))) {
    255       first = first_orig;
    256       return false;
    257     }
    258     first+2;
     254    if (match(first, last, std::string("//")).empty()) {
     255      first = first_orig;
     256      return false;
     257    }
    259258    std::string new_path = match(first, last, not2Char('@', ' '));
    260259    if (*first!='@'){
     
    341340      return false;
    342341    }
     342    ++first; // eating ']'
    343343    std::string href(Configuration::instance().trac_root()+"log/?rev="+
    344344                     rev+"&stop_rev="+stop_rev);
     
    396396    const std::string::const_iterator first_orig(first);
    397397
    398     if (match(first, last, Str("milestone:")).empty()){
     398    if (match(first, last, std::string("milestone:")).empty()){
    399399      first = first_orig;
    400400      return false;
     
    427427      if (log(first, str.end()))
    428428        continue;
     429      if (comment(first, str.end()))
     430        continue;
    429431      if (ticket(first, str.end()))
    430         continue;
    431       if (comment(first, str.end()))
    432432        continue;
    433433      if (changeset(first, str.end()))
     
    453453    const std::string::const_iterator first_orig(first);
    454454
    455     if (match(first, last, Str("source:")).empty()){
     455    if (match(first, last, std::string("source:")).empty()){
    456456      first = first_orig;
    457457      return false;
     
    531531    const std::string::const_iterator first_orig(first);
    532532
    533     if (match(first, last, Str("ticket:")).empty()){
    534       first = first_orig;
    535       return false;
    536     }
    537      
     533    if (match(first, last, std::string("ticket:")).empty()){
     534      first = first_orig;
     535      return false;
     536    }
    538537    std::string ticket = match(first, last, Digit());
    539538
    540539    const Configuration& conf = Configuration::instance();
    541     hs_.stream() << anchor(conf.trac_root()+"ticket/"+ticket,"#"+ticket);
     540    hs_.stream() << anchor(conf.trac_root()+"ticket/"+ticket,
     541                           std::string(first_orig, first));
    542542    return true;
    543543  }
  • trunk/lib/Trac.h

    r308 r309  
    119119
    120120    ///
    121     /// \brief search for diff:trunk@12+:123
     121    /// \brief search for diff:trunk@12:123
    122122    ///
    123123    /// Search in range [\a first, \a last) for expression
     
    136136
    137137    ///
    138     /// @brief search for diff:tags/1.0 or diff:tags/1.0//1.0.1
     138    /// @brief search for diff:tags/1.0 or diff:tags/1.0//tags/1.0.1
    139139    ///
    140140    /// Search in range [\a first, \a last) for expression
     
    162162    ///
    163163    /// The created anchor goes to
    164     /// trac-root/changeset?new=236&new_path=trunk&old=236&old_path=tags/1.0
     164    /// trac-root/changeset?new=236&new_path=trunk&old=123&old_path=tags/1.0
    165165    ///
    166166    /// @return true if expression is found
  • trunk/lib/html_utility.cc

    r289 r309  
    4646    for (size_t i=0; i<level; ++i)
    4747      ss << "../";
    48     hs << href;
     48    ss << href;
    4949    ss << "\">";
    5050    hs << name;
  • trunk/lib/utility.cc

    r303 r309  
    174174
    175175
     176  std::string match(std::string::const_iterator& first,
     177                    const std::string::const_iterator& last,
     178                    std::string str)
     179  {
     180    if (match_begin(first, last, str)){
     181      first+=str.size();
     182      return str;
     183    }
     184    return std::string();
     185  }
     186
    176187  notChar::notChar(char c)
    177188    : char_(c)
     
    183194  {}
    184195   
    185 
    186   Str::Str(std::string s)
    187     : str_(s)
    188   {}
    189 
    190196
    191197  not2Str::not2Str(std::string s1, std::string s2)
  • trunk/lib/utility.h

    r308 r309  
    150150  }
    151151
     152
     153  std::string match(std::string::const_iterator& first,
     154                    const std::string::const_iterator& last,
     155                    std::string);
     156
    152157  struct AlNum
    153158  {
     
    183188    const char char1_;
    184189    const char char2_;
    185   };
    186 
    187   class Str
    188   {
    189   public:
    190     Str(std::string);
    191     inline bool operator()(std::string::const_iterator i) const
    192     { return (std::equal(str_.begin(), str_.end(), i)); }
    193 
    194   private:
    195     const std::string str_;
    196190  };
    197191
  • trunk/test/Makefile.am

    r267 r309  
    44
    55# Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
     6# Copyright (C) 2007 Peter Johansson
    67#
    78# This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
     
    2223# 02111-1307, USA.
    2324
    24 check_PROGRAMS = gnuplot_pipe parser
     25check_PROGRAMS = gnuplot_pipe parser trac
    2526
    2627TESTS = $(check_PROGRAMS)
     
    3637gnuplot_pipe_SOURCES = gnuplot_pipe.cc
    3738parser_SOURCES = parser.cc
     39trac_SOURCES = trac.cc
    3840
    3941test_repo.sh: test_repo.sh.in Makefile.am
Note: See TracChangeset for help on using the changeset viewer.