-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringToIntTester.cpp
More file actions
38 lines (35 loc) · 1.03 KB
/
StringToIntTester.cpp
File metadata and controls
38 lines (35 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// FOR TESTING ONLY--DO NOT TURN IN
// Alfred Ledgin
// 10/31/2015
// CS 303
// Project 4
#include <iostream>
#include <string>
#include "StringToInt.h"
using namespace std;
int main()
{
StringToInt converterA("123");
cout << converterA.obtainInt() << endl;
StringToInt converterB;
cout << converterB.obtainInt() << endl;
converterB.input("54321");
cout << converterB.obtainInt() << endl;
cout << (converterB.obtainInt() + 1) << endl;
cout << (converterB.obtainInt() * 10) << endl;
cout << -(converterB.obtainInt()) << endl;
try
{converterB.input("1a2");}
catch(exception)
{cout << "Converting '1a2' raises exception as expected." << endl;}
try
{converterB.input("-12");}
catch(exception)
{cout << "Converting '-12' raises exception as expected." << endl;}
StringToInt converterC;
cout << converterC.obtainInt("789") << endl;
cout << (converterC.obtainInt("456") + 1) << endl;
cout << (converterC.obtainInt("456") * 10) << endl;
system("pause");
return 0;
}