~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/tests/testStoreEntryStream.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "squid.h"
 
2
#include "Mem.h"
 
3
#include "testStore.h"
 
4
#include "testStoreEntryStream.h"
 
5
#include "CapturingStoreEntry.h"
 
6
#include "Store.h"
 
7
#include "StoreEntryStream.h"
 
8
 
 
9
#include <iomanip>
 
10
 
 
11
#include <cppunit/TestAssert.h>
 
12
 
 
13
CPPUNIT_TEST_SUITE_REGISTRATION( testStoreEntryStream );
 
14
 
 
15
/* init memory pools */
 
16
 
 
17
struct Initer
 
18
{
 
19
    Initer() {Mem::Init();}
 
20
};
 
21
 
 
22
static Initer ensure_mempools;
 
23
 
 
24
void
 
25
testStoreEntryStream::testGetStream()
 
26
{
 
27
    /* Setup a store root so we can create a StoreEntry */
 
28
    StorePointer aStore (new TestStore);
 
29
    Store::Root(aStore);
 
30
 
 
31
    CapturingStoreEntry * anEntry = new CapturingStoreEntry();
 
32
    {
 
33
        StoreEntryStream stream(anEntry);
 
34
        CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls);
 
35
        CPPUNIT_ASSERT_EQUAL(0, anEntry->_flush_calls);
 
36
        stream << "some text" << std::setw(4) << "!";
 
37
        CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls);
 
38
        CPPUNIT_ASSERT_EQUAL(0, anEntry->_flush_calls);
 
39
        stream.flush();
 
40
        CPPUNIT_ASSERT_EQUAL(1, anEntry->_buffer_calls);
 
41
        CPPUNIT_ASSERT_EQUAL(1, anEntry->_flush_calls);
 
42
        CPPUNIT_ASSERT_EQUAL(String("some text   !"), anEntry->_appended_text);
 
43
    }
 
44
 
 
45
    delete anEntry;
 
46
 
 
47
    Store::Root(NULL);
 
48
}