]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
Tests for foreign records
authorJavier Sancho <jsf@jsancho.org>
Mon, 30 Dec 2019 19:31:06 +0000 (20:31 +0100)
committerJavier Sancho <jsf@jsancho.org>
Mon, 30 Dec 2019 19:31:06 +0000 (20:31 +0100)
tests/foreign-record.scm [new file with mode: 0644]

diff --git a/tests/foreign-record.scm b/tests/foreign-record.scm
new file mode 100644 (file)
index 0000000..06343b1
--- /dev/null
@@ -0,0 +1,49 @@
+;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
+;;; Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+;;;
+;;; This file is part of guile-irrlicht.
+;;;
+;;; Guile-irrlicht is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU Lesser General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; Guile-irrlicht is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with guile-irrlicht.  If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+
+(use-modules (system foreign)
+             (srfi srfi-64)
+             (irrlicht util))
+
+(test-begin "foreign-record")
+
+;; Dimension 2D definition
+(define-foreign-record-type dimension2d
+  (make-dimension2d width height)
+  dimension2d?
+  dimension2d-pointer
+  (width uint32 dimension2d-width set-dimension2d-width!)
+  (height uint32 dimension2d-height set-dimension2d-height!))
+
+;; Create dimension
+(define dim (make-dimension2d 10 20))
+(test-equal 10 (dimension2d-width dim))
+(test-equal 20 (dimension2d-height dim))
+
+;; Modify dimension
+(set-dimension2d-width! dim 50)
+(set-dimension2d-height! dim 100)
+(test-equal 50 (dimension2d-width dim))
+(test-equal 100 (dimension2d-height dim))
+
+;; Is a pointer
+(test-assert (pointer? (dimension2d-pointer dim)))
+
+(test-end "foreign-record")