On 10/17/2010 10:55 AM, Paolo Bonzini wrote:

> 
> I suggest using the former, for which I added a shortcut #asCData in git,
> together with a similar shortcut for Strings: ('123' asCData) is the same as
> ('123' asCData: CCharType).
>

Thanks. I have added a very primitive testcase for these methods.
>From 084a6ceac788a3c317e451698257364adfb5845a Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <ze...@selfish.org>
Date: Mon, 18 Oct 2010 09:13:46 +0200
Subject: [PATCH] Add test code for the new asCData selector

Test it on the ByteArray and the String.
---
 ChangeLog         |    6 ++++++
 tests/cobjects.ok |   13 +++++++++++++
 tests/cobjects.st |   22 ++++++++++++++++++++++
 3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f307718..3506244 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-17  Holger Hans Peter Freyther  <ze...@selfish.org>
+
+	* tests/cobject.st: Add client code for ByteArray>>#asCData and
+	String>>#asCData.
+	* tests/cobject.ok: Update the result.
+
 2010-10-17  Paolo Bonzini <bonz...@gnu.org>
 
 	* kernel/String.st: Document NULL-termination of output of
diff --git a/tests/cobjects.ok b/tests/cobjects.ok
index f241507..d05d3f1 100644
--- a/tests/cobjects.ok
+++ b/tests/cobjects.ok
@@ -136,3 +136,16 @@ Execution begins...
 'abc'
 'def'
 returned value is CPtr new: 1 "<0>"
+
+Execution begins...
+1
+2
+3
+returned value is nil
+
+Execution begins...
+$1
+$2
+$3
+$<0>
+returned value is nil
diff --git a/tests/cobjects.st b/tests/cobjects.st
index 25688ba..a902461 100644
--- a/tests/cobjects.st
+++ b/tests/cobjects.st
@@ -202,5 +202,27 @@ Eval [
     c
 ]
 
+" Play with conversion for ByteArray"
+Eval [
+    c := #(1 2 3) asByteArray.
+    d := c asCData.
+    (d at: 0) printNl.
+    (d at: 1) printNl.
+    (d at: 2) printNl.
+    d free.
+    d free.
+]
+
+" Plat with conversion for String"
+Eval [
+    c := '123' asCData.
+    (c at: 0) printNl.
+    (c at: 1) printNl.
+    (c at: 2) printNl.
+    (c at: 3) printNl.
+    c free.
+    c free.
+]
+
 " ### need a lot more!"
 
-- 
1.7.3.1

_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to