]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testStoreEntryStream.cc
1 #define SQUID_UNIT_TEST 1
6 #include "testStoreEntryStream.h"
7 #include "CapturingStoreEntry.h"
9 #include "StoreEntryStream.h"
13 #include <cppunit/TestAssert.h>
15 CPPUNIT_TEST_SUITE_REGISTRATION( testStoreEntryStream
);
17 /* init memory pools */
19 void testStoreEntryStream::setUp()
25 testStoreEntryStream::testGetStream()
27 /* Setup a store root so we can create a StoreEntry */
28 StorePointer
aStore (new TestStore
);
31 CapturingStoreEntry
* anEntry
= new CapturingStoreEntry();
33 StoreEntryStream
stream(anEntry
);
34 CPPUNIT_ASSERT_EQUAL(1, anEntry
->_buffer_calls
);
35 CPPUNIT_ASSERT_EQUAL(0, anEntry
->_flush_calls
);
37 stream
.setf(std::ios::fixed
);
38 stream
<< 123456 << std::setprecision(1) << 77.7;
39 stream
<< " some text" << std::setw(4) << "!" << '.';
40 CPPUNIT_ASSERT_EQUAL(1, anEntry
->_buffer_calls
);
42 const int preFlushCount
= anEntry
->_flush_calls
;
43 // may have already flushed
44 CPPUNIT_ASSERT(preFlushCount
>= 0);
46 // flushed at least once more
47 CPPUNIT_ASSERT(anEntry
->_flush_calls
> preFlushCount
);
49 CPPUNIT_ASSERT_EQUAL(1, anEntry
->_buffer_calls
);
51 CPPUNIT_ASSERT_EQUAL(String("12345677.7 some text !."),
52 anEntry
->_appended_text
);