equal
deleted
inserted
replaced
|
1 //============================================================================ |
|
2 // Name : teststrings.cpp |
|
3 // Author : Lasse Nielson |
|
4 // |
|
5 // Description : Generation of Test Strings for Regular Expressions |
|
6 // |
|
7 // Compile : g++ -o teststrings teststrings.cpp |
|
8 //============================================================================ |
|
9 |
|
10 #include <iostream> |
|
11 #include <string> |
|
12 #include <sstream> |
|
13 |
|
14 using namespace std; |
|
15 |
|
16 string str_email(int n) { |
|
17 stringstream ss; |
|
18 for (int i = 0; i < n; ++i) { |
|
19 for (int j = 0; j < i % 27 + 3; ++j) |
|
20 ss << (char) ('a' + (j % 26)); |
|
21 if (n > i + 1) |
|
22 ss << "-"; |
|
23 } |
|
24 ss << "@"; |
|
25 for (int j = 0; j < 2; ++j) { |
|
26 for (int i = 0; i < n + 3; ++i) |
|
27 ss << (char) ('a' + ((i + j) % 26)); |
|
28 ss << "."; |
|
29 } |
|
30 ss << "com"; |
|
31 return ss.str(); |
|
32 } |
|
33 |
|
34 string str_amount(int n) { |
|
35 stringstream ss; |
|
36 ss << "$"; |
|
37 for (int i = 0; i < n; ++i) { |
|
38 ss << (1 + i) % 10; |
|
39 if (n > i + 1 && (n - i) % 3 == 1) |
|
40 ss << ","; |
|
41 } |
|
42 ss << ".53"; |
|
43 return ss.str(); |
|
44 } |
|
45 |
|
46 string str_float(int n) { |
|
47 stringstream ss; |
|
48 ss << "-"; |
|
49 for (int i = 0; i < n; ++i) { |
|
50 ss << (1 + i) % 10; |
|
51 } |
|
52 ss << "."; |
|
53 for (int i = 0; i < n; ++i) { |
|
54 ss << (1 + i) % 10; |
|
55 } |
|
56 ss << "E+"; |
|
57 for (int i = 0; i < n; ++i) { |
|
58 ss << (1 + i) % 10; |
|
59 } |
|
60 return ss.str(); |
|
61 } |
|
62 |
|
63 int main() { |
|
64 |
|
65 int fin = 10; |
|
66 |
|
67 // emails |
|
68 for (int i = 1; i < fin; i++) { |
|
69 cout << str_email(i) << endl; |
|
70 } |
|
71 |
|
72 // dollar amounts |
|
73 for (int i = 1; i < fin; i++) { |
|
74 cout << str_amount(i) << endl; |
|
75 } |
|
76 |
|
77 // float numbers |
|
78 for (int i = 1; i < fin; i++) { |
|
79 cout << str_float(i) << endl; |
|
80 } |
|
81 |
|
82 return 0; |
|
83 } |