aboutsummaryrefslogtreecommitdiff
path: root/src/cctest
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-10-07 15:03:15 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-10-07 15:03:15 +0000
commitf2834a96b24c1d3c4fcfd31a704b17b9fd4ec6e1 (patch)
treee62e3adb6f2b0321859ad0aa68d76faddc2eda6f /src/cctest
parent19fe222179a7c51ce950e304140425b5218baf85 (diff)
Modified Files:
README namespace/makefile the default compiler should be g++, not gcc Added Files: vector/README vector/makefile vector/status vector/vector-global.cc vector/vector-std:std-vector.cc vector/vector-std:using-namespace-std.cc vector/vector-std:using-std-vector.cc vector/vector_h-global.cc vector/vector_h-std:std-vector.cc vector/vector_h-std:using-namespace-std.cc vector/vector_h-std:using-std-vector.cc new set of test programs to test namespace usage for the STL vector class git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@799 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/cctest')
-rw-r--r--src/cctest/README8
-rw-r--r--src/cctest/namespace/makefile2
-rw-r--r--src/cctest/vector/README28
-rw-r--r--src/cctest/vector/makefile58
-rw-r--r--src/cctest/vector/status12
-rw-r--r--src/cctest/vector/vector-global.cc17
-rw-r--r--src/cctest/vector/vector-std:std-vector.cc17
-rw-r--r--src/cctest/vector/vector-std:using-namespace-std.cc18
-rw-r--r--src/cctest/vector/vector-std:using-std-vector.cc18
-rw-r--r--src/cctest/vector/vector_h-global.cc17
-rw-r--r--src/cctest/vector/vector_h-std:std-vector.cc17
-rw-r--r--src/cctest/vector/vector_h-std:using-namespace-std.cc18
-rw-r--r--src/cctest/vector/vector_h-std:using-std-vector.cc18
13 files changed, 246 insertions, 2 deletions
diff --git a/src/cctest/README b/src/cctest/README
index 2d515a0..c817d1d 100644
--- a/src/cctest/README
+++ b/src/cctest/README
@@ -1,2 +1,8 @@
This directory contains subdirectories with test programs for
-various C++ compiler/library features.
+various C++ compiler/library features:
+
+namespace/ This directory tests how namespaces are handled for
+ C standard library functions, eg <stdio.h> vs <cstdio>
+
+vector/ This directory test how namespaces are handled for
+ the STL vector class, eg <vector.h> vs <cvector>
diff --git a/src/cctest/namespace/makefile b/src/cctest/namespace/makefile
index 0c76e63..007f689 100644
--- a/src/cctest/namespace/makefile
+++ b/src/cctest/namespace/makefile
@@ -11,7 +11,7 @@
#
# default setting, may be overridden from command line
-CXX := gcc -W -Wall -pedantic -ansi
+CXX := g++ -W -Wall -pedantic -ansi
.PHONY : default
default : stdio_h cstdio
diff --git a/src/cctest/vector/README b/src/cctest/vector/README
new file mode 100644
index 0000000..1a68a4b
--- /dev/null
+++ b/src/cctest/vector/README
@@ -0,0 +1,28 @@
+$Header$
+
+This directory contains a set of "hello, world" programs to test how
+C++ namespaces are handled for the STL vector class.
+
+Each .cc file is a "hello, world\n" program using a particular set of
+options for what header file to #include, what (if any) using declarations
+or definitions to use, and whether or not to use an explicit std::
+qualifier when referring to the vector class.
+
+According to standard C++, #include <vector> puts names *only* in the
+std:: namespace, so the vector-global.cc program should fail to compile.
+All the other programs should be legal in standard C++.
+
+ what to what namespace how we call status
+ #include? are we using vector()? in
+ vector() in? standard
+ using? C++
+
+vector_h-global.cc <vector.h> global -- vector() ok
+vector_h-std:std-vector.cc <vector.h> std -- std::vector() ok
+vector_h-std:using-std-vector.cc <vector.h> std std::vector; vector() ok
+vector_h-std:using-namespace-std.cc <vector.h> std namespace std; vector() ok
+
+vector-global.cc <vector> global -- vector() WRONG
+vector-std:std-vector.cc <vector> std -- std::vector() ok
+vector-std:using-std-vector.cc <vector> std std::vector; vector() ok
+vector-std:using-namespace-std.cc <vector> std namespace std; vector() ok
diff --git a/src/cctest/vector/makefile b/src/cctest/vector/makefile
new file mode 100644
index 0000000..ed84c84
--- /dev/null
+++ b/src/cctest/vector/makefile
@@ -0,0 +1,58 @@
+# Makefile to test various C/C++ compiler features
+#
+# Targets:
+# default test namespace handling for <vector.h> and <vector>
+# vector_h test namespace handling for <vector.h>
+# vector test namespace handling for <vector>
+# clean remove all binaries
+#
+# Arguments:
+# CXX how to invoke the C++ compiler, including any desired flags
+#
+
+# default setting, may be overridden from command line
+CXX := g++ -W -Wall -pedantic -ansi
+
+.PHONY : default
+default : vector_h vector
+
+.PHONY : vector_h
+vector_h :
+ -$(CXX) -o vector_h-global \
+ vector_h-global.cc
+ -./vector_h-global
+ -$(CXX) -o vector_h-std:std-vector \
+ vector_h-std:std-vector.cc
+ -./vector_h-std:std-vector
+ -$(CXX) -o vector_h-std:using-std-vector \
+ vector_h-std:using-std-vector.cc
+ -./vector_h-std:using-std-vector
+ -$(CXX) -o vector_h-std:using-namespace-std \
+ vector_h-std:using-namespace-std.cc
+ -./vector_h-std:using-namespace-std
+
+.PHONY : vector
+vector :
+ -$(CXX) -o vector-global \
+ vector-global.cc
+ -./vector-global
+ -$(CXX) -o vector-std:std-vector \
+ vector-std:std-vector.cc
+ -./vector-std:std-vector
+ -$(CXX) -o vector-std:using-std-vector \
+ vector-std:using-std-vector.cc
+ -./vector-std:using-std-vector
+ -$(CXX) -o vector-std:using-namespace-std \
+ vector-std:using-namespace-std.cc
+ -./vector-std:using-namespace-std
+
+.PHONY : clean
+clean :
+ -rm -f vector_h-global \
+ vector_h-std:std-vector \
+ vector_h-std:using-std-vector \
+ vector_h-std:using-namespace-std
+ -rm -f vector-global \
+ vector-std:std-vector \
+ vector-std:using-std-vector \
+ vector-std:using-namespace-std
diff --git a/src/cctest/vector/status b/src/cctest/vector/status
new file mode 100644
index 0000000..2950a37
--- /dev/null
+++ b/src/cctest/vector/status
@@ -0,0 +1,12 @@
+osmium.aei.mpg.de # OpenBSD 3.1
+gcc version 2.95.3 20010125 (prerelease)
+Sun Oct 6 21:15:55 EDT 2002
+CXX='/usr/bin/g++ -W -Wall -ansi -pedantic'
+==> #include <vector.h>; vector is ok
+==> #include <vector.h>; std::vector is ok
+==> #include <vector.h>; using std::vector; vector is ok
+==> #include <vector.h>; using namespace std; vector is ok
+==> #include <vector>; vector is ok (THIS SHOULD FAIL)
+==> #include <vector>; std::vector is ok
+==> #include <vector>; using std::vector; vector is ok
+==> #include <vector>; using namespace std; vector is ok
diff --git a/src/cctest/vector/vector-global.cc b/src/cctest/vector/vector-global.cc
new file mode 100644
index 0000000..b582306
--- /dev/null
+++ b/src/cctest/vector/vector-global.cc
@@ -0,0 +1,17 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector>
+
+int main()
+{
+printf("testing <vector> functions in global namespace (THIS SHOULD FAIL):\n");
+vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector>; vector is ok (THIS SHOULD FAIL)\n");
+return 0;
+}
diff --git a/src/cctest/vector/vector-std:std-vector.cc b/src/cctest/vector/vector-std:std-vector.cc
new file mode 100644
index 0000000..25d4b48
--- /dev/null
+++ b/src/cctest/vector/vector-std:std-vector.cc
@@ -0,0 +1,17 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector>
+
+int main()
+{
+printf("testing <vector> functions in std:: namespace:\n");
+std::vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector>; std::vector is ok\n");
+return 0;
+}
diff --git a/src/cctest/vector/vector-std:using-namespace-std.cc b/src/cctest/vector/vector-std:using-namespace-std.cc
new file mode 100644
index 0000000..df8b7f2
--- /dev/null
+++ b/src/cctest/vector/vector-std:using-namespace-std.cc
@@ -0,0 +1,18 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector>
+using namespace std;
+
+int main()
+{
+printf("testing <vector> functions in std:: namespace:\n");
+vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector>; using namespace std; vector is ok\n");
+return 0;
+}
diff --git a/src/cctest/vector/vector-std:using-std-vector.cc b/src/cctest/vector/vector-std:using-std-vector.cc
new file mode 100644
index 0000000..20870e0
--- /dev/null
+++ b/src/cctest/vector/vector-std:using-std-vector.cc
@@ -0,0 +1,18 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector>
+using std::vector;
+
+int main()
+{
+printf("testing <vector> functions in std:: namespace:\n");
+vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector>; using std::vector; vector is ok\n");
+return 0;
+}
diff --git a/src/cctest/vector/vector_h-global.cc b/src/cctest/vector/vector_h-global.cc
new file mode 100644
index 0000000..1fe0d03
--- /dev/null
+++ b/src/cctest/vector/vector_h-global.cc
@@ -0,0 +1,17 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector.h>
+
+int main()
+{
+printf("testing <vector.h> functions in global namespace:\n");
+vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector.h>; vector is ok\n");
+return 0;
+}
diff --git a/src/cctest/vector/vector_h-std:std-vector.cc b/src/cctest/vector/vector_h-std:std-vector.cc
new file mode 100644
index 0000000..696513f
--- /dev/null
+++ b/src/cctest/vector/vector_h-std:std-vector.cc
@@ -0,0 +1,17 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector.h>
+
+int main()
+{
+printf("testing <vector.h> functions in std:: namespace:\n");
+std::vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector.h>; std::vector is ok\n");
+return 0;
+}
diff --git a/src/cctest/vector/vector_h-std:using-namespace-std.cc b/src/cctest/vector/vector_h-std:using-namespace-std.cc
new file mode 100644
index 0000000..f76758d
--- /dev/null
+++ b/src/cctest/vector/vector_h-std:using-namespace-std.cc
@@ -0,0 +1,18 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector.h>
+using namespace std;
+
+int main()
+{
+printf("testing <vector.h> functions in std:: namespace:\n");
+vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector.h>; using namespace std; vector is ok\n");
+return 0;
+}
diff --git a/src/cctest/vector/vector_h-std:using-std-vector.cc b/src/cctest/vector/vector_h-std:using-std-vector.cc
new file mode 100644
index 0000000..6934061
--- /dev/null
+++ b/src/cctest/vector/vector_h-std:using-std-vector.cc
@@ -0,0 +1,18 @@
+// $Header$
+
+#include <stdio.h>
+#include <vector.h>
+using std::vector;
+
+int main()
+{
+printf("testing <vector.h> functions in std:: namespace:\n");
+vector<int> v(3);
+v[0] = 42;
+v[1] = 69;
+v[2] = 105;
+printf("%d %d %d should be 42 69 105... ", v[0], v[1], v[2]);
+printf(((v[0] == 42) && (v[1] == 69) && (v[2] == 105)) ? "ok\n" : "FAIL\n");
+printf("==> #include <vector.h>; using std::vector; vector is ok\n");
+return 0;
+}