File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ char const* MemoryOutStream::GetText() const
10
10
return m_text.c_str ();
11
11
}
12
12
13
+ void MemoryOutStream::Clear ()
14
+ {
15
+ this ->str (std::string ());
16
+ m_text = this ->str ();
17
+ }
18
+
13
19
}
14
20
15
21
#else
@@ -52,6 +58,11 @@ MemoryOutStream::~MemoryOutStream()
52
58
delete [] m_buffer;
53
59
}
54
60
61
+ void MemoryOutStream::Clear ()
62
+ {
63
+ m_buffer[0 ] = ' \0 ' ;
64
+ }
65
+
55
66
char const * MemoryOutStream::GetText () const
56
67
{
57
68
return m_buffer;
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ class UNITTEST_LINKAGE MemoryOutStream : public std::ostringstream
16
16
public:
17
17
MemoryOutStream () {}
18
18
~MemoryOutStream () {}
19
- char const * GetText () const ;
19
+ void Clear ();
20
+ char const * GetText () const ;
20
21
21
22
private:
22
23
MemoryOutStream (MemoryOutStream const &);
@@ -40,6 +41,7 @@ class UNITTEST_LINKAGE MemoryOutStream
40
41
explicit MemoryOutStream (int const size = 256 );
41
42
~MemoryOutStream ();
42
43
44
+ void Clear ();
43
45
char const * GetText () const ;
44
46
45
47
MemoryOutStream& operator <<(char const * txt);
Original file line number Diff line number Diff line change @@ -103,6 +103,14 @@ TEST(StreamingSizeTWritesCorrectCharacters)
103
103
CHECK_EQUAL (" 53124" , stream.GetText ());
104
104
}
105
105
106
+ TEST (ClearEmptiesMemoryOutStreamContents)
107
+ {
108
+ MemoryOutStream stream;
109
+ stream << " Hello world" ;
110
+ stream.Clear ();
111
+ CHECK_EQUAL (" " , stream.GetText ());
112
+ }
113
+
106
114
#ifndef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
107
115
108
116
TEST (StreamInitialCapacityIsCorrect)
You can’t perform that action at this time.
0 commit comments