[SCM] Tcl interface to FITS Files branch, debian, updated. 0a11ab7b5e225e9fd696be323972143e3b40c8ba

Ole Streicher debian at liska.ath.cx
Wed Aug 22 14:23:54 UTC 2012


The following commit has been merged in the debian branch:
commit 0a11ab7b5e225e9fd696be323972143e3b40c8ba
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Wed Aug 22 16:20:27 2012 +0200

    Include some unit tests in build process

diff --git a/debian/rules b/debian/rules
index ad5cc23..c3b0ded 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,5 +7,8 @@
 override_dh_auto_configure:
 	dh_auto_configure -- --with-tcl-includes=/usr/include/tcl
 
+override_dh_auto_test:
+	(cd debian/tests; TCLLIBPATH=../.. tclsh all.tcl)
+
 override_dh_installchangelogs:
 	dh_installchangelogs ReleaseNotes
diff --git a/debian/tests/all.tcl b/debian/tests/all.tcl
new file mode 100644
index 0000000..ba0acc1
--- /dev/null
+++ b/debian/tests/all.tcl
@@ -0,0 +1,6 @@
+#!/usr/bin/tclsh
+# This file is a -*- tcl -*- file
+
+package require tcltest
+namespace import ::tcltest::*
+runAllTests
diff --git a/debian/tests/image.test b/debian/tests/image.test
new file mode 100644
index 0000000..6169b5f
--- /dev/null
+++ b/debian/tests/image.test
@@ -0,0 +1,81 @@
+#!/usr/bin/tclsh
+# This file is a -*- tcl -*- file
+
+package require tcltest 2.0
+namespace import ::tcltest::*  
+
+package require fitsTcl
+
+# Set up an empty image with 3x4 pixel size, save it and re-open the 
+# image extension.
+set img [fits open image.fits 2]
+$img insert image -p
+$img insert image 8 2 {4 3}
+$img close
+
+set img [fits open image.fits\[1\] 0]
+
+test fits-info {
+    Return a list of all the existing objects, or the named objects
+} {
+    fits info $img
+} "{fitsObj1 {image.fits\[1\]} 0 2 0}"
+
+test info-chdu {
+    Return the CHDU. 1=primary, 2=first extension, etc
+} {
+    return [$img info chdu]
+} 2
+
+test info-filesize {
+    Return the size of the file (in units of 2880 bytes)
+} {
+    return [$img info filesize]
+} 3
+
+test info-hdutype {
+    Return "Primary array", "Image extension", "Binary Table", or "ASCII Table"
+} {
+    return [$img info hdutype]
+} "Image extension"
+
+test info-imgdim {
+    Return the dimensions of the image
+} {
+    return [$img info imgdim]
+} {4 3}
+
+test info-nkwds {
+    Return the number of keywords in the header of the CHDU
+} {
+    return [$img info nkwds]
+} 8
+
+test dump {
+    Return the CHDU. 1=primary, 2=first extension, etc
+} {
+    return [$img dump -l]
+} {XTENSION BITPIX NAXIS NAXIS1 NAXIS2 PCOUNT GCOUNT}
+
+test get-header2str {
+    get header and construct it into a string
+} {
+    return [ string  length [$img get header2str]]
+} 644
+
+test get-keyword {
+    Return a list of {keyword value comment} for all the keywords in keyList
+} {
+    return [$img get keyword XTENSION]
+} {{XTENSION {'IMAGE   '} {IMAGE extension}}}
+
+test get-image {
+    Read data elements from the current IMAGE extension and return them in 
+    a list
+} {
+    return [$img get image 1 3]
+} {0 0 0}
+
+fits close
+file delete image.fits
+cleanupTests
diff --git a/debian/tests/other.test b/debian/tests/other.test
new file mode 100644
index 0000000..17c9baf
--- /dev/null
+++ b/debian/tests/other.test
@@ -0,0 +1,29 @@
+#!/usr/bin/tclsh
+# This file is a -*- tcl -*- file
+#
+package require tcltest 2.0
+namespace import ::tcltest::*  
+
+package require fitsTcl
+
+test other-option {
+    Return a list of all the current fitsTcl options and their values.
+} {
+    fits option
+} "{wcsSwap 0}"
+
+test other-version {
+    Get version numbers for fitsTcl and underlying cfitsio. 
+} {
+    set version [fits version]
+    return [string range $version 0 2]
+} 2.3
+
+test other-range-count {
+    Count the number of elements contained within the comma-separated list of 
+    ranges in rangeStr
+} {
+    range count 1-4,7- 11
+} 9
+
+cleanupTests
diff --git a/debian/tests/table.test b/debian/tests/table.test
new file mode 100644
index 0000000..c4d0302
--- /dev/null
+++ b/debian/tests/table.test
@@ -0,0 +1,80 @@
+#!/usr/bin/tclsh
+# This file is a -*- tcl -*- file
+
+package require tcltest 2.0
+namespace import ::tcltest::*  
+
+package require fitsTcl
+
+# Set up a table
+set tbl [fits open table.fits 2]
+$tbl insert table 3 {target V_mag} {20A E12.5}
+$tbl put table target 1 - { NGC1001 NGC1002 NGC1003 }
+$tbl put table V_mag 1 - { 11.1 12.3 15.2 }
+$tbl close
+
+set tbl [fits open table.fits\[1\] 0]
+
+test fits-info {
+    Return a list of all the existing objects, or the named objects
+} {
+    fits info $tbl
+} "{fitsObj1 {table.fits\[1\]} 0 2 2}"
+
+test info-chdu {
+    Return the CHDU. 1=primary, 2=first extension, etc
+} {
+    return [$tbl info chdu]
+} 2
+
+test info-filesize {
+    Return the size of the file (in units of 2880 bytes)
+} {
+    return [$tbl info filesize]
+} 3
+
+test info-hdutype-tbl {
+    Return "Primary array", "Image extension", "Binary Table", or "ASCII Table"
+} {
+    return [$tbl info hdutype]
+} "Binary Table"
+
+test info-ncols {
+    Return the number of columns in the table
+} {
+    return [$tbl info ncols]
+} 2
+
+test info-nrows {
+    Return the number of rows in the table
+} {
+    return [$tbl info nrows]
+} 3
+
+test info-nkwds {
+    Return the number of keywords in the header of the CHDU
+} {
+    return [$tbl info nkwds]
+} 13
+
+test dump {
+    Return the CHDU. 1=primary, 2=first extension, etc
+} {
+    return [$tbl dump -l]
+} {XTENSION BITPIX NAXIS NAXIS1 NAXIS2 PCOUNT GCOUNT TFIELDS TTYPE1 TFORM1 TTYPE2 TFORM2}
+
+test get-keyword {
+    Return a list of {keyword value comment} for all the keywords in keyList
+} {
+    return [$tbl get keyword XTENSION]
+} {{XTENSION 'BINTABLE' {binary table extension}}}
+
+test get-table {
+    Read a block of a table and return list(s) of data
+} {
+    return [$tbl get table * 1]
+} {{NGC1001 1.110000E+01}}
+
+fits close
+file delete table.fits
+cleanupTests

-- 
Tcl interface to FITS Files



More information about the debian-science-commits mailing list