From d05d093854bdadad03456fbccc1a2da490ce410a Mon Sep 17 00:00:00 2001 From: Mike Wey Date: Wed, 23 Feb 2011 23:25:17 +0100 Subject: Add Geometry.d --- dmagick/Utils.d | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'dmagick/Utils.d') 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) { -- cgit v1.2.3