summaryrefslogtreecommitdiff
path: root/src/unittest/strnumtest.cc
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-10-02 11:26:59 -0700
committerNathan Binkert <nate@binkert.org>2008-10-02 11:26:59 -0700
commit52493b27202fb61aaae74779ebcd91ca8f2bbc2c (patch)
treeeafc46fbeb182b85c766910dfcef544df2e1723a /src/unittest/strnumtest.cc
parent67a2918abc057f8f6d693d8acadd70bf9337cf44 (diff)
downloadgem5-52493b27202fb61aaae74779ebcd91ca8f2bbc2c.tar.xz
unittest: Cleanup unit tests. Follow style. Garbage Collect.
--HG-- rename : src/unittest/rangemaptest2.cc => src/unittest/rangemultimaptest.cc
Diffstat (limited to 'src/unittest/strnumtest.cc')
-rw-r--r--src/unittest/strnumtest.cc63
1 files changed, 31 insertions, 32 deletions
diff --git a/src/unittest/strnumtest.cc b/src/unittest/strnumtest.cc
index ea28e35df..0e234884d 100644
--- a/src/unittest/strnumtest.cc
+++ b/src/unittest/strnumtest.cc
@@ -28,8 +28,7 @@
* Authors: Nathan Binkert
*/
-#include <iostream.h>
-
+#include <iostream>
#include <string>
#include <vector>
@@ -40,39 +39,39 @@ using namespace std;
int
main(int argc, char *argv[])
{
- if (argc != 2) {
- cout << "Usage: " << argv[0] << " <number>\n";
- exit(1);
- }
+ if (argc != 2) {
+ cout << "Usage: " << argv[0] << " <number>\n";
+ exit(1);
+ }
- string s = argv[1];
+ string s = argv[1];
#define OUTVAL(valtype, type) do { \
- valtype value; \
- cout << "TYPE = " #valtype "\n"; \
- if (to_number(s, value)) { \
- cout << "Number(" << s << ") = " << dec \
- << (unsigned long long)(unsigned type)value << "\n" \
- << "Number(" << s << ") = " << dec \
- << (signed long long)(signed type)value << "\n" \
- << "Number(" << s << ") = 0x" << hex \
- << (unsigned long long)(unsigned type)value << "\n" \
- << "Number(" << s << ") = 0" << oct \
- << (unsigned long long)(unsigned type)value << "\n\n"; \
- } else \
- cout << "Number(" << s << ") is invalid\n\n"; \
- } while (0)
+ valtype value; \
+ cout << "TYPE = " #valtype "\n"; \
+ if (to_number(s, value)) { \
+ cout << "Number(" << s << ") = " << dec \
+ << (unsigned long long)(unsigned type)value << "\n" \
+ << "Number(" << s << ") = " << dec \
+ << (signed long long)(signed type)value << "\n" \
+ << "Number(" << s << ") = 0x" << hex \
+ << (unsigned long long)(unsigned type)value << "\n" \
+ << "Number(" << s << ") = 0" << oct \
+ << (unsigned long long)(unsigned type)value << "\n\n"; \
+ } else \
+ cout << "Number(" << s << ") is invalid\n\n"; \
+ } while (0)
- OUTVAL(signed long long, long long);
- OUTVAL(unsigned long long, long long);
- OUTVAL(signed long, long);
- OUTVAL(unsigned long, long);
- OUTVAL(signed int, int);
- OUTVAL(unsigned int, int);
- OUTVAL(signed short, short);
- OUTVAL(unsigned short, short);
- OUTVAL(signed char, char);
- OUTVAL(unsigned char, char);
+ OUTVAL(signed long long, long long);
+ OUTVAL(unsigned long long, long long);
+ OUTVAL(signed long, long);
+ OUTVAL(unsigned long, long);
+ OUTVAL(signed int, int);
+ OUTVAL(unsigned int, int);
+ OUTVAL(signed short, short);
+ OUTVAL(unsigned short, short);
+ OUTVAL(signed char, char);
+ OUTVAL(unsigned char, char);
- return 0;
+ return 0;
}