summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2004-02-07 01:16:50 -0500
committerNathan Binkert <binkertn@umich.edu>2004-02-07 01:16:50 -0500
commitde285ff2a0c49fdf61dba7c4fcc6b3804e045e56 (patch)
tree1833b004064f005d92ad195208a1eead0d0dbde5 /test
parent6d6c91f756a84fdf06da823b79a8e9b27e2c4a7f (diff)
downloadgem5-de285ff2a0c49fdf61dba7c4fcc6b3804e045e56.tar.xz
Totally rework the Range class. Now the range is from [start, end)
to be consistent with the way that the stl works. It also makes lots of other stuff easier. (Maybe those guys were smart?) Overload the various comparison operators so that you can test for overlapping of ranges, etc. base/range.hh: Totally rework the Range class. Now the range is from [start, end) to be consistent with the way that the stl works. It also makes lots of other stuff easier. (Maybe those guys were smart?) Overload the various comparison operators so that you can test for overlapping of ranges, etc. make parse function private and offer operator= instead isValid -> valid and for you erik, I add comments test/Makefile: add range.o test/rangetest.cc: better tests --HG-- extra : convert_revision : dd58720aa3d02f20b03e933f2eaa3320c82bb27a
Diffstat (limited to 'test')
-rw-r--r--test/Makefile2
-rw-r--r--test/rangetest.cc78
2 files changed, 25 insertions, 55 deletions
diff --git a/test/Makefile b/test/Makefile
index 2c3780c93..d62dba64a 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -49,7 +49,7 @@ nmtest: nmtest.o object_file.o symtab.o misc.o str.o
offtest: offtest.o
$(CXX) $(LFLAGS) -o $@ $^
-rangetest: rangetest.o str.o
+rangetest: rangetest.o range.o str.o
$(CXX) $(LFLAGS) -o $@ $^
stattest: cprintf.o hostinfo.o misc.o python.o statistics.o stattest.o \
diff --git a/test/rangetest.cc b/test/rangetest.cc
index f44d835b7..c38c13fd1 100644
--- a/test/rangetest.cc
+++ b/test/rangetest.cc
@@ -31,11 +31,12 @@
#include "base/range.hh"
+using namespace std;
int
main()
{
- Range<int> r1(9, 28);
+ Range<int> r1(make_pair(9, 28));
Range<unsigned> r2("0x1000:+0x100");
cout << r1 << "\n"
@@ -44,61 +45,30 @@ main()
#define RANGETEST(X, C, Y) \
cout << X << " "#C" " << Y << " => " << ((X C Y) ? "true" : "false") << "\n"
- int i1 = 10;
- int i2 = 0x1001;
- RANGETEST(i1, < , r1);
- RANGETEST(i1, <=, r1);
- RANGETEST(i1, > , r1);
- RANGETEST(i1, >=, r1);
- RANGETEST(i1, ==, r1);
- RANGETEST(i1, !=, r1);
- RANGETEST(r1, < , i1);
- RANGETEST(r1, <=, i1);
- RANGETEST(r1, > , i1);
- RANGETEST(r1, >=, i1);
- RANGETEST(r1, ==, i1);
- RANGETEST(r1, !=, i1);
+#define TESTEM(X, Y) do { \
+ RANGETEST(X, < , Y); \
+ RANGETEST(X, <=, Y); \
+ RANGETEST(X, > , Y); \
+ RANGETEST(X, >=, Y); \
+ RANGETEST(X, ==, Y); \
+ RANGETEST(X, !=, Y); \
+ RANGETEST(Y, < , X); \
+ RANGETEST(Y, <=, X); \
+ RANGETEST(Y, > , X); \
+ RANGETEST(Y, >=, X); \
+ RANGETEST(Y, ==, X); \
+ RANGETEST(Y, !=, X); \
+} while (0)
- RANGETEST(i2, < , r1);
- RANGETEST(i2, <=, r1);
- RANGETEST(i2, > , r1);
- RANGETEST(i2, >=, r1);
- RANGETEST(i2, ==, r1);
- RANGETEST(i2, !=, r1);
- RANGETEST(r1, < , i2);
- RANGETEST(r1, <=, i2);
- RANGETEST(r1, > , i2);
- RANGETEST(r1, >=, i2);
- RANGETEST(r1, ==, i2);
- RANGETEST(r1, !=, i2);
+ TESTEM(8, r1);
+ TESTEM(9, r1);
+ TESTEM(27, r1);
+ TESTEM(28, r1);
- unsigned u1 = 10;
- unsigned u2 = 0x1001;
- RANGETEST(u1, < , r2);
- RANGETEST(u1, <=, r2);
- RANGETEST(u1, > , r2);
- RANGETEST(u1, >=, r2);
- RANGETEST(u1, ==, r2);
- RANGETEST(u1, !=, r2);
- RANGETEST(r2, < , u1);
- RANGETEST(r2, <=, u1);
- RANGETEST(r2, > , u1);
- RANGETEST(r2, >=, u1);
- RANGETEST(r2, ==, u1);
- RANGETEST(r2, !=, u1);
-
- RANGETEST(u2, < , r2);
- RANGETEST(u2, <=, r2);
- RANGETEST(u2, > , r2);
- RANGETEST(u2, >=, r2);
- RANGETEST(u2, ==, r2);
- RANGETEST(u2, !=, r2);
- RANGETEST(r2, < , u2);
- RANGETEST(r2, <=, u2);
- RANGETEST(r2, > , u2);
- RANGETEST(r2, >=, u2);
- RANGETEST(r2, ==, u2);
- RANGETEST(r2, !=, u2);
+ TESTEM(0x0fff, r2);
+ TESTEM(0x1000, r2);
+ TESTEM(0x10ff, r2);
+ TESTEM(0x1100, r2);
return 0;
}