summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/testRegistry.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-09-16 12:20:48 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-09-16 12:20:48 (GMT)
commit0b30d230855d9b1fd7891996f1b9120abcf1df5b (patch)
tree79d61d9979b64523c1efb894b86933ca0a22166f /Source/kwsys/testRegistry.cxx
parent656357a47506012d63ccfb15119aa168931fb1b2 (diff)
downloadCMake-0b30d230855d9b1fd7891996f1b9120abcf1df5b.zip
CMake-0b30d230855d9b1fd7891996f1b9120abcf1df5b.tar.gz
CMake-0b30d230855d9b1fd7891996f1b9120abcf1df5b.tar.bz2
ENH: Initial import
Diffstat (limited to 'Source/kwsys/testRegistry.cxx')
-rw-r--r--Source/kwsys/testRegistry.cxx94
1 files changed, 94 insertions, 0 deletions
diff --git a/Source/kwsys/testRegistry.cxx b/Source/kwsys/testRegistry.cxx
new file mode 100644
index 0000000..4f304d8
--- /dev/null
+++ b/Source/kwsys/testRegistry.cxx
@@ -0,0 +1,94 @@
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile$
+
+ Copyright (c) Kitware, Inc.
+ All rights reserved.
+ See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "kwsysPrivate.h"
+
+#include KWSYS_HEADER(Registry.hxx)
+#include KWSYS_HEADER(ios/iostream)
+
+// Work-around CMake dependency scanning limitation. This must
+// duplicate the above list of headers.
+#if 0
+# include "Registry.hxx.in"
+# include "kwsys_ios_iostream.h.in"
+#endif
+
+#define IFT(x,res) if ( !x ) \
+ { \
+ res = 1; \
+ kwsys_ios::cout << "Error in: " << #x << kwsys_ios::endl; \
+ }
+#define IFNT(x,res) if ( x ) \
+ { \
+ res = 1; \
+ kwsys_ios::cout << "Error in: " << #x << kwsys_ios::endl; \
+ }
+
+#define CHE(x,y,res) if ( strcmp(x,y) ) \
+ { \
+ res = 1; \
+ kwsys_ios::cout << "Error, " << x << " != " << y << kwsys_ios::endl; \
+ }
+
+int main(int, char**)
+{
+ int res = 0;
+
+ kwsys::Registry reg;
+ reg.SetTopLevel("TestRegistry");
+
+ IFT(reg.SetValue("TestSubkey", "TestKey1", "Test Value 1"), res);
+ IFT(reg.SetValue("TestSubkey1", "TestKey2", "Test Value 2"), res);
+ IFT(reg.SetValue("TestSubkey", "TestKey3", "Test Value 3"), res);
+ IFT(reg.SetValue("TestSubkey2", "TestKey4", "Test Value 4"), res);
+
+ char buffer[1024];
+ IFT(reg.ReadValue("TestSubkey", "TestKey1", buffer), res);
+ CHE(buffer, "Test Value 1", res);
+ IFT(reg.ReadValue("TestSubkey1", "TestKey2", buffer), res);
+ CHE(buffer, "Test Value 2", res);
+ IFT(reg.ReadValue("TestSubkey", "TestKey3", buffer), res);
+ CHE(buffer, "Test Value 3", res);
+ IFT(reg.ReadValue("TestSubkey2", "TestKey4", buffer), res);
+ CHE(buffer, "Test Value 4", res);
+
+ IFT(reg.SetValue("TestSubkey", "TestKey1", "New Test Value 1"), res);
+ IFT(reg.SetValue("TestSubkey1", "TestKey2", "New Test Value 2"), res);
+ IFT(reg.SetValue("TestSubkey", "TestKey3", "New Test Value 3"), res);
+ IFT(reg.SetValue("TestSubkey2", "TestKey4", "New Test Value 4"), res);
+
+ IFT(reg.ReadValue("TestSubkey", "TestKey1", buffer), res);
+ CHE(buffer, "New Test Value 1", res);
+ IFT(reg.ReadValue("TestSubkey1", "TestKey2", buffer), res);
+ CHE(buffer, "New Test Value 2", res);
+ IFT(reg.ReadValue("TestSubkey", "TestKey3", buffer), res);
+ CHE(buffer, "New Test Value 3", res);
+ IFT(reg.ReadValue("TestSubkey2", "TestKey4", buffer), res);
+ CHE(buffer, "New Test Value 4", res);
+
+ IFT( reg.DeleteValue("TestSubkey", "TestKey1"), res);
+ IFNT(reg.ReadValue( "TestSubkey", "TestKey1", buffer), res);
+ IFT( reg.DeleteValue("TestSubkey1", "TestKey2"), res);
+ IFNT(reg.ReadValue( "TestSubkey1", "TestKey2", buffer), res);
+ IFT( reg.DeleteValue("TestSubkey", "TestKey3"), res);
+ IFNT(reg.ReadValue( "TestSubkey", "TestKey3", buffer), res);
+ IFT( reg.DeleteValue("TestSubkey2", "TestKey4"), res);
+ IFNT(reg.ReadValue( "TestSubkey2", "TestKey5", buffer), res);
+
+ if ( res )
+ {
+ kwsys_ios::cout << "Test failed" << kwsys_ios::endl;
+ }
+ return res;
+}