root/branches/3.00/src/tests/UserSettingTest.cc

Revision 644, 1.5 kB (checked in by fujii, 3 years ago)

Add new netinstall source.

Line 
1 /*
2  * Copyright (c) 2003, Robert Collins
3  *
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  *
9  *     A copy of the GNU General Public License can be found at
10  *     http://www.gnu.org/
11  *
12  * Written by Robert Collins <rbtcollins@hotmail.com>
13  *
14  */
15
16 #if 0
17 static const char *cvsid =
18   "\n%%% $Id: UserSettingTest.cc,v 1.1 2003/07/26 07:08:43 rbcollins Exp $\n";
19 #endif
20
21 #include "site.h"
22 #include "win32.h"
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <process.h>
27 #include <algorithm>
28
29 #include "LogSingleton.h"
30 #include "io_stream.h"
31
32 #include "port.h"
33 #include "Exception.h"
34 #include "UserSetting.h"
35 #include "UserSettings.h"
36
37 using namespace std;
38
39 class TestSetting : public UserSetting {
40   public:
41   TestSetting();
42   static TestSetting &getInstance();
43   virtual void load();
44   virtual void save();
45   void testPassed();
46   private:
47   static TestSetting Instance;
48   bool loaded;
49   bool saved;
50 };
51
52 TestSetting &
53 TestSetting::getInstance()
54 {
55  return Instance;
56 }
57
58 TestSetting TestSetting::Instance;
59
60 TestSetting::TestSetting() : loaded(false), saved(false) {}
61
62 void
63 TestSetting::load()
64 {
65  loaded = true;
66 }
67
68 void
69 TestSetting::save()
70 {
71  saved = true;
72 }
73
74 void
75 TestSetting::testPassed()
76 {
77  if (saved)
78  exit(1);
79  if(loaded)
80  exit(1);
81 }
82
83 #ifdef ASTEST
84 int
85 main (int argc, char **argv)
86 {
87   TestSetting::getInstance().testPassed();
88   return 0;
89 }
90 #endif
Note: See TracBrowser for help on using the browser.