3f66f6a5b3
This keyword is not expanded by Git which means it's not replaced with the correct revision value in the releases made using git-based scripts and it's confusing to have lines with unexpanded "$Id$" in the released files. As expanding them with Git is not that simple (it could be done with git archive and export-subst attribute) and there are not many benefits in having them in the first place, just remove all these lines. If nothing else, this will make an eventual transition to Git simpler. Closes #14487. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
85 lines
2.3 KiB
C++
85 lines
2.3 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Name: tests/streams/tempfile.cpp
|
|
// Purpose: Test wxTempFileOutputStream
|
|
// Author: Mike Wetherell
|
|
// Copyright: (c) 2005 Mike Wetherell
|
|
// Licence: wxWindows licence
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "testprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
// for all others, include the necessary headers
|
|
#ifndef WX_PRECOMP
|
|
#include "wx/wx.h"
|
|
#endif
|
|
|
|
#include "wx/wfstream.h"
|
|
#include "wx/filename.h"
|
|
#include "bstream.h"
|
|
|
|
#if wxUSE_STREAMS && wxUSE_FILE
|
|
|
|
#include "testfile.h"
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// The test case
|
|
|
|
class tempStream : public CppUnit::TestCase
|
|
{
|
|
CPPUNIT_TEST_SUITE(tempStream);
|
|
CPPUNIT_TEST(DoNothing);
|
|
CPPUNIT_TEST(Close);
|
|
CPPUNIT_TEST(Commit);
|
|
CPPUNIT_TEST(Discard);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
void DoNothing() { DoTest(DONOTHING, false); }
|
|
void Close() { DoTest(CLOSE, true); }
|
|
void Commit() { DoTest(COMMIT, true); }
|
|
void Discard() { DoTest(DISCARD, false); }
|
|
|
|
enum Action { DONOTHING, CLOSE, COMMIT, DISCARD };
|
|
void DoTest(Action action, bool shouldHaveCommited);
|
|
};
|
|
|
|
// the common test code
|
|
//
|
|
void tempStream::DoTest(Action action, bool shouldHaveCommited)
|
|
{
|
|
TestFile temp;
|
|
|
|
{
|
|
wxTempFileOutputStream out(temp.GetName());
|
|
out.Write("Affer", 5);
|
|
CPPUNIT_ASSERT(out.SeekO(2) == 2);
|
|
out.Write("t", 1);
|
|
CPPUNIT_ASSERT(out.IsSeekable());
|
|
CPPUNIT_ASSERT(out.GetLength() == 5);
|
|
CPPUNIT_ASSERT(out.TellO() == 3);
|
|
|
|
switch (action) {
|
|
case DONOTHING: break;
|
|
case COMMIT: out.Commit(); break;
|
|
case DISCARD: out.Discard(); break;
|
|
case CLOSE: out.Close();
|
|
}
|
|
}
|
|
|
|
wxFileInputStream in(temp.GetName());
|
|
char buf[32];
|
|
in.Read(buf, sizeof(buf));
|
|
buf[in.LastRead()] = 0;
|
|
CPPUNIT_ASSERT(strcmp(buf, shouldHaveCommited ? "After" : "Before") == 0);
|
|
}
|
|
|
|
|
|
// Register the stream sub suite, by using some stream helper macro.
|
|
// Note: Don't forget to connect it to the base suite (See: bstream.cpp => StreamCase::suite())
|
|
STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(tempStream)
|
|
|
|
#endif // wxUSE_STREAMS && wxUSE_FILE
|