summaryrefslogtreecommitdiff
path: root/test/MockSegment.h
blob: 7e4e4fb2734308ee46466a2a0e19c86a15f051bc (plain)
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
#ifndef D_MOCK_SEGMENT_H
#define D_MOCK_SEGMENT_H

#include "Segment.h"
#include "Piece.h"
#include "A2STR.h"

namespace aria2 {

class MockSegment:public Segment {
public:
  virtual bool complete() const
  {
    return false;
  }

  virtual size_t getIndex() const
  {
    return 0;
  }

  virtual off_t getPosition() const
  {
    return 0;
  }
  
  virtual off_t getPositionToWrite() const
  {
    return 0;
  }

  virtual int32_t getLength() const
  {
    return 0;
  }

  virtual int32_t getSegmentLength() const
  {
    return 0;
  }

  virtual int32_t getWrittenLength() const
  {
    return 0;
  }

  virtual void updateWrittenLength(int32_t bytes) {}

#ifdef ENABLE_MESSAGE_DIGEST

  // `begin' is a offset inside this segment.
  virtual bool updateHash
  (int32_t begin, const unsigned char* data, size_t dataLength)
  {
    return false;
  }

  virtual bool isHashCalculated() const
  {
    return false;
  }

  virtual std::string getDigest()
  {
    return A2STR::NIL;
  }

#endif // ENABLE_MESSAGE_DIGEST

  virtual void clear() {}

  virtual SharedHandle<Piece> getPiece() const
  {
    return SharedHandle<Piece>();
  }
};

} // namespace aria2

#endif // D_MOCK_SEGMENT_H