Operators with std::string
[libacl.git] / test / superstring_assign.cpp
1 /*******************************************************
2  *  Unit test for the SuperString class
3  *
4  * test contrustor and assignment of SuperSting objects
5  ******************************************************
6  *
7  */
8
9 #include "String.h"
10 #include <assert.h>
11
12 int main()
13 {
14    // Default contructor: empty string
15    SuperString s0;
16
17    std::cout << "The default contructor makes an empty superstring.\n";
18    assert(~s0 == 0);
19
20    String s1("abc");
21    SuperString ss1(s1);
22
23    std::cout << "Contructor from a String makes a superstring with 1 element.\n";
24    assert(~ss1 == 1);
25
26    SuperString ss2(4);
27
28    std::cout << "Contructor with an integer argument makes a superstring with n elements.\n";
29    assert(~ss2 == 4);
30
31    // The copy contructor
32
33    SuperString ss3(ss2);
34
35    std::cout << "The copy contructor makes a bitwise copy.\n";
36    assert(~ss3 == 4);
37
38    //  Assignment to a SuperSting with n elements should remove the old elements.
39
40    return 0;
41
42    // A string from a literal string
43    String s2("abc");
44
45    std::cout << "A string from a literal string \"abc\": \"" << s2 << "\"\n";
46    assert(~s2 == 3);
47
48    // The copy constructor
49    String s3(s2);
50
51    std::cout << "A string copied from the previous string \"abc\": \"" << s3 << "\"\n";
52    assert(~s3 == 3);
53
54    // Assign a single character
55    String s4;
56    s4 = 'q';
57    std::cout << "A string assigned a single charater 'q': \"" << s4 << "\"\n";
58    assert(~s4 == 1);
59
60    // Initialized with a single character
61    String s5 = 'r';
62
63    std::cout << "A string initialized with a single charater 'r': \"" << s5 << "\"\n";
64    assert(~s5 == 1);
65
66    // Assign a literal string
67    String s6;
68    s6 = "ijk";
69    std::cout << "A string assigned a literal string \"ijk\": \"" << s6 << "\"\n";
70    assert(~s6 == 3);
71
72    // Initialized a literal string
73    String s7 = "lmn";
74    
75    std::cout << "A string initialized with a literal string \"lmn\": \"" << s7 << "\"\n";
76    assert(~s7 == 3);
77
78    // Assign a String object
79    String s8;
80    s8 = s6;
81    std::cout << "A string assigned a String object \"ijk\": \"" << s8 << "\"\n";
82    assert(~s8 == 3);
83
84    // Initialized a String object
85    String s9 = s7;
86    
87    std::cout << "A string initialized with a String object \"lmn\": \"" << s9 << "\"\n";
88    assert(~s9 == 3);
89
90    return 0;
91 }
92