home *** CD-ROM | disk | FTP | other *** search
- //
- // $Id: AppPreferencesStreamTest.cc,v 1.1.1.1 2000/06/02 22:22:57 sergey Exp $
- //
-
- #include <Pilot.h>
- #include <stdio.h>
- #include "../Test.h"
- #include "Util/AppPreferencesInputStream.h"
- #include "Util/AppPreferencesOutputStream.h"
-
-
- namespace Util
- {
- const char* TestString = "Hello!";
- const DWord CreatorID = 'PrCT';
-
- class AppPreferencesStreamTest: public Test
- {
- public:
- virtual const char* name() const { return "AppPreferencesStreamTest"; }
-
- virtual void runTest()
- {
- testOutputStream();
- testInputStream();
- }
-
- void testOutputStream()
- {
- AppPreferencesOutputStream stream;
-
- stream.open(CreatorID, 0, 0);
-
- stream.write((long)3);
- stream.write(TestString);
- stream.write((int)1);
- stream.write((char)2);
-
- stream.open(CreatorID, 0, 0);
- stream.close();
- }
-
- void testInputStream()
- {
- AppPreferencesInputStream stream;
-
- testAssert(stream.open(CreatorID, 0));
-
- testAssert(stream.readAs<long>() == 3);
-
- char buff[256];
- int readSize = strlen(TestString)+1;
- testAssert(stream.readAsString(buff, readSize) == readSize);
- testAssert(StrCompare(TestString, buff) == 0);
-
- testAssert(stream.readAs<int>() == 1);
- testAssert(stream.readAs<char>() == 2);
- }
- };
- }
-
- Test& GetAppPreferencesStreamTest()
- {
- static Util::AppPreferencesStreamTest test;
- return test;
- }
-