Mercurial > projects > ldc
comparison tests/mini/bug33.d @ 341:1bb99290e03a trunk
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author | lindquist |
---|---|
date | Sun, 13 Jul 2008 02:51:19 +0200 |
parents | test/bug33.d@28e99b04a132 |
children |
comparison
equal
deleted
inserted
replaced
340:351c0077d0b3 | 341:1bb99290e03a |
---|---|
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 } |