1 /**************************************************************************
2 ** (c) Copyright 1999, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
6 ** FILE NAME : acltest.cpp
7 ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
8 ** VERSION NUMBER : $Revision: 1.1 $
10 ** DESCRIPTION : Test routine for non-X classes
15 ***************************************************************************
16 ** ADMINISTRATIVE INFORMATION *
17 ********************************
18 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
19 ** CREATION DATE : Feb 06, 1998
20 ** LAST UPDATE : Oct 16, 1999
21 **************************************************************************/
23 /*****************************
25 Revision 1.1 2002-07-25 08:01:18 arjen
26 First checkin, AXE release 0.2
28 *****************************/
30 static const char *RCSID = "$Id: acltest.cpp,v 1.1 2002-07-25 08:01:18 arjen Exp $";
34 #include "complex/complex.h"
39 String hello = "Hello there";
40 String points, pattern;
42 cout << hello << ",length= " << ~hello << "\n";
43 cout << "4th character = " << hello[3] << " (Changed to L)\n";
47 cout << "Points is not empty\n";
49 cout << "Points is empty\n";
53 cout << "after assignment: Points is not empty\n";
55 cout << "after assignment: points is empty\n";
57 hello += points + String("!??");
58 cout << "Catenated: " << hello << ",length= " << ~hello << "\n";
60 cout << "Substring(10,3) = " << String(hello(10,3)) << "\n";
63 cout << "hello(10,3)=points ->hello = " << hello << "\n";
64 cout << "Substring(8,9) = " << String(hello(8,9)) << "\n";
66 cout << "Converted to upper case: " << hello.upper() << "\n";
67 cout << "Converted to lower case: " << hello.lower() << "\n";
70 cout << "hello(8,9)=__ ->hello = " << hello << "\n";
72 cout << "Removing with hello(8,7) = \"\": " << hello << "\n";
74 cout << "Inserting with hello(8,0) = \"ere \": " << hello << "\n";
75 hello(5, ~hello-5) = "";
76 cout << "Truncating with hello(5, ~hello-5) = \"\": " << hello << "\n";
78 cout << "String shifting:\n";
82 cout << x << " << 3 = " << y << "\n";
84 cout << x << " >> 3 = " << y << "\n";
86 cout << "\nInput a string:\n";
88 cout << hello << "\n\n";
89 cout << "\nAnd another one:\n";
91 cout << pattern << "\n\n";
92 cout << "Second string found at position " << pattern.in(hello);
93 cout << " of first string.\n";
95 cout << "Construct a string from an int: ";
99 cout << "***********************\nInteger Test\n*********************\n";
100 integer a(2000000000), b(2048);
103 cout << "a = " << a << ", b = " << b << "\n";
104 cout << "c = " << c << "\n";
106 cout << "c = b : c = " << c << "\n";
108 cout << "***********************\nComplex Number Test\n*********************\n";
115 cout << z1 << " + " << z2 << " = " << z3 << "\n";
117 cout << z1 << " - " << z2 << " = " << z3 << "\n";
119 cout << z1 << " * " << z2 << " = " << z3 << "\n";
121 cout << z1 << " / " << z2 << " = " << z3 << "\n";
124 cout << "***********************\nDate Test\n*********************\n";
125 date d1, d2(22,7,1964);
127 cout << "Default constructor: " << d1 << ", with (d,m,y): " << d2 << "\n";
128 cout << "Enter a date: \n";
133 d2 = date(datestring);
135 cout << datestring << " parses into (DD-MM-YYYY): " << d2 << "\n";
136 datestring = d2.format();
137 cout << "Formatted date: " << datestring << "\n";
141 cout << "Size of a date is " << sizeof(d1) << "\n";
143 cout << "365 days after " << d2 << " is " << d2 + 365 << "\n";
146 cout << "365 days was converted to " << d3 << "\n";
147 cout << "Added to the date you entered: " << d2 + d3 << "\n";
149 cout << d2 << " == " << d1 << " is " << (d2 == d1) << "\n";
150 cout << d2 << " != " << d1 << " is " << (d2 != d1) << "\n";
151 cout << d2 << " >= " << d1 << " is " << (d2 >= d1) << "\n";
152 cout << d2 << " <= " << d1 << " is " << (d2 <= d1) << "\n";
153 cout << d2 << " > " << d1 << " is " << (d2 > d1) << "\n";
154 cout << d2 << " < " << d1 << " is " << (d2 < d1) << "\n";
156 cout << "difference is " << d2 - d1 << " days.\n\n";
158 cout << "***********************\nTime Test\n*********************\n";
162 cout << "Default constructor: " << t1 << "\n";
163 t1 = hour(10, 50, 30);
164 cout << "With 10,50,30: " << t1 << "\n";
165 cout << "Enter a time: \n";
168 t2 = hour(datestring);
170 cout << datestring << " parses into (HH:MM:SS): " << t2 << "\n";
172 cout << "t1 + t2 = " << t1 + t2 << "\n";
173 cout << "t1 - t2 = " << t1 - t2 << "\n";
174 cout << "t2 - t1 = " << t2 - t1 << "\n";