Mercurial > projects > dstress
comparison run/mini/bug33.d @ 1628:c6ef09dfba4d
add mini test set from ldc project
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Mon, 10 Jan 2011 19:47:18 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1627:e1b954780837 | 1628:c6ef09dfba4d |
---|---|
1 module bug33; | |
2 | |
3 extern(C) int memcmp(void*,void*,size_t); | |
4 | |
5 private int string_cmp(char[] s1, char[] s2) | |
6 { | |
7 auto len = s1.length; | |
8 if (s2.length < len) | |
9 len = s2.length; | |
10 int result = memcmp(s1.ptr, s2.ptr, len); | |
11 if (result == 0) | |
12 result = cast(int)(cast(ptrdiff_t)s1.length - cast(ptrdiff_t)s2.length); | |
13 return result; | |
14 } | |
15 | |
16 struct S | |
17 { | |
18 char[] toString() | |
19 { | |
20 return "S"; | |
21 } | |
22 } | |
23 | |
24 int func() | |
25 { | |
26 S a,b; | |
27 return string_cmp(a.toString(),b.toString()); | |
28 } | |
29 | |
30 void main() | |
31 { | |
32 assert(func() == 0); | |
33 } |