]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not assume that store stream cannot flush its contents into the store entry
authorrousskov <>
Wed, 8 Aug 2007 01:45:51 +0000 (01:45 +0000)
committerrousskov <>
Wed, 8 Aug 2007 01:45:51 +0000 (01:45 +0000)
unless we call the flush method. Depending on stream implementation, it is
possible that the stream will flush while we add data to it and before we
call flush().

Added more store stream output cases, including floating point numbers and
their formatting.

src/tests/testStoreEntryStream.cc

index 3beb0805475efc9e4d1e7cf5143c142ef16e5736..b6a4f5f6e6326176e1f8b4242f9f6cbc2f152fa3 100644 (file)
@@ -31,13 +31,23 @@ testStoreEntryStream::testGetStream()
         StoreEntryStream stream(anEntry);
         CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls);
         CPPUNIT_ASSERT_EQUAL(0, anEntry->_flush_calls);
-        stream << "some text" << std::setw(4) << "!";
+
+        stream.setf(std::ios::fixed);
+        stream << 123456 << std::setprecision(1) << 77.7;
+        stream << " some text" << std::setw(4) << "!" << '.';
         CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls);
-        CPPUNIT_ASSERT_EQUAL(0, anEntry->_flush_calls);
+
+        const int preFlushCount = anEntry->_flush_calls;
+        // may have already flushed
+        CPPUNIT_ASSERT(preFlushCount >= 0); 
         stream.flush();
+        // flushed at least once more
+        CPPUNIT_ASSERT(anEntry->_flush_calls > preFlushCount);
+
         CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls);
-        CPPUNIT_ASSERT_EQUAL(1, anEntry->_flush_calls);
-        CPPUNIT_ASSERT_EQUAL(String("some text   !"), anEntry->_appended_text);
+
+        CPPUNIT_ASSERT_EQUAL(String("12345677.7 some text   !."), 
+anEntry->_appended_text);
     }
 
     delete anEntry;