From 5f5b7536e4f044eb617925db8d4df9b02be3ba7d Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 30 Dec 2019 20:31:06 +0100 Subject: [PATCH 1/1] Tests for foreign records --- tests/foreign-record.scm | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/foreign-record.scm diff --git a/tests/foreign-record.scm b/tests/foreign-record.scm new file mode 100644 index 0000000..06343b1 --- /dev/null +++ b/tests/foreign-record.scm @@ -0,0 +1,49 @@ +;;; guile-irrlicht --- FFI bindings for Irrlicht Engine +;;; Copyright (C) 2019 Javier Sancho +;;; +;;; 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 +;;; . + + +(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") -- 2.39.5