forked from dlang/phobos
-
Notifications
You must be signed in to change notification settings - Fork 2
/
unittest.d
137 lines (121 loc) · 3.67 KB
/
unittest.d
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Written in the D programming language.
/**
* This test program pulls in all the library modules in order to run the unit
* tests on them. Then, it prints out the arguments passed to main().
*
* Copyright: Copyright Digital Mars 2000 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: $(WEB digitalmars.com, Walter Bright)
*
* Copyright Digital Mars 2000 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
version(Win64) {}
else
{
public import std.base64;
public import std.compiler;
public import std.concurrency;
public import std.conv;
public import std.cstream;
public import std.datetime;
public import std.demangle;
public import std.file;
public import std.format;
public import std.getopt;
public import std.math;
public import std.mathspecial;
public import std.metastrings;
public import std.mmfile;
public import std.outbuffer;
public import std.parallelism;
public import std.path;
public import std.process;
public import std.random;
public import std.regex;
public import std.signals;
//public import std.slist;
public import std.socket;
public import std.socketstream;
public import std.stdint;
public import std.stdio;
public import std.stream;
public import std.string;
public import std.syserror;
public import std.system;
public import std.traits;
public import std.typetuple;
public import std.uni;
public import std.uri;
public import std.utf;
public import std.uuid;
public import std.variant;
public import std.zip;
public import std.zlib;
public import std.net.isemail;
public import std.net.curl;
public import std.digest.digest;
public import std.digest.crc;
public import std.digest.sha;
public import std.digest.md;
}
int main(char[][] args)
{
version(Win64) {}
else
{
// Bring in unit test for module by referencing function in it
cmp("foo", "bar"); // string
filenameCharCmp('a', 'b'); // path
isNaN(1.0); // math
std.conv.to!double("1.0"); // std.conv
OutBuffer b = new OutBuffer(); // outbuffer
auto r = regex(""); // regex
uint ranseed = std.random.unpredictableSeed;
thisTid;
int a[];
a.reverse; // adi
a.sort; // qsort
Clock.currTime(); // datetime
Exception e = new ReadException(""); // stream
din.eof(); // cstream
isValidDchar(cast(dchar)0); // utf
std.uri.ascii2hex(0); // uri
std.zlib.adler32(0,null); // D.zlib
auto t = task!cmp("foo", "bar"); // parallelism
creal c = 3.0 + 4.0i;
c = sqrt(c);
assert(c.re == 2);
assert(c.im == 1);
printf("args.length = %d\n", args.length);
for (int i = 0; i < args.length; i++)
printf("args[%d] = '%s'\n", i, cast(char *)args[i]);
int[3] x;
x[0] = 3;
x[1] = 45;
x[2] = -1;
x.sort;
assert(x[0] == -1);
assert(x[1] == 3);
assert(x[2] == 45);
std.math.sin(3.0);
std.mathspecial.gamma(6.2);
std.demangle.demangle("hello");
std.uni.isAlpha('A');
std.file.exists("foo");
foreach_reverse (dchar d; "hello"c) { }
foreach_reverse (k, dchar d; "hello"c) { }
std.signals.linkin();
bool isEmail = std.net.isemail.isEmail("abc");
auto http = std.net.curl.HTTP("dlang.org");
auto uuid = randomUUID();
auto md5 = md5Of("hello");
auto sha1 = sha1Of("hello");
auto crc = crc32Of("hello");
auto string = toHexString(crc);
puts("Success!");
}
return 0;
}