diff options
| author | Mike Wey | 2011-02-23 23:25:17 +0100 |
|---|---|---|
| committer | Mike Wey | 2011-02-23 23:25:17 +0100 |
| commit | d05d093854bdadad03456fbccc1a2da490ce410a (patch) | |
| tree | 2aa59739c4df18fb120b8120d0301fc9886d4714 /dmagick/Utils.d | |
| parent | 0bbb355681ad7a9dc3be943152d68e90e4ff0974 (diff) | |
Add Geometry.d
Diffstat (limited to 'dmagick/Utils.d')
| -rw-r--r-- | dmagick/Utils.d | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/dmagick/Utils.d b/dmagick/Utils.d index b7ebd33..2429626 100644 --- a/dmagick/Utils.d +++ b/dmagick/Utils.d @@ -35,13 +35,15 @@ void copyString(ref char[MaxTextExtent] dest, string source) * We use this since using CloneString forces us to * append a \0 to the end of the string, and the realocation * whould be wastefull if we are just going to copy it + * + * used for copying a string into a Imagemagick struct */ void copyString(ref char* dest, string source) { if ( source is null ) { if ( dest !is null ) - DestroyString(dest); + dest = DestroyString(dest); return; } @@ -62,6 +64,25 @@ void copyString(ref char* dest, string source) dest[source.length] = '\0'; } +unittest +{ + char* dest; + string source = "test"; + + copyString(dest, source); + + assert( dest !is source.ptr ); + assert( dest[0..5] == "test\0" ); + + copyString(dest, "unit"); + assert( dest[0..5] == "unit\0" ); + + copyString(dest, null); + assert( dest is null ); +} + +void main(){} + /** */ real degreesToRadians(real deg) { |
