Annotation of loncom/xml/lontable.test, revision 1.1

1.1     ! foxr        1: #!/usr/bin/perl
        !             2: 
        !             3: # The LearningOnline Network with CAPA
        !             4: #  Generating TeX tables.
        !             5: #
        !             6: # $Id: lontable.pm,v 1.3 2008/12/01 12:25:06 foxr Exp $
        !             7: # 
        !             8: #
        !             9: # Copyright Michigan State University Board of Trustees
        !            10: #
        !            11: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
        !            12: #
        !            13: # LON-CAPA is free software; you can redistribute it and/or modify
        !            14: # it under the terms of the GNU General Public License as published by
        !            15: # the Free Software Foundation; either version 2 of the License, or
        !            16: # (at your option) any later version.
        !            17: #
        !            18: # LON-CAPA is distributed in the hope that it will be useful,
        !            19: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            20: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            21: # GNU General Public License for more details.
        !            22: #
        !            23: # You should have received a copy of the GNU General Public License
        !            24: # along with LON-CAPA; if not, write to the Free Software
        !            25: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        !            26: #
        !            27: # /home/httpd/html/adm/gpl.txt
        !            28: #
        !            29: # http://www.lon-capa.org/
        !            30: ## Copyright for TtHfunc and TtMfunc by Ian Hutchinson. 
        !            31: # TtHfunc and TtMfunc (the "Code") may be compiled and linked into 
        !            32: # binary executable programs or libraries distributed by the 
        !            33: # Michigan State University (the "Licensee"), but any binaries so 
        !            34: # distributed are hereby licensed only for use in the context
        !            35: # of a program or computational system for which the Licensee is the 
        !            36: # primary author or distributor, and which performs substantial 
        !            37: # additional tasks beyond the translation of (La)TeX into HTML.
        !            38: # The C source of the Code may not be distributed by the Licensee
        !            39: # to any other parties under any circumstances.
        !            40: #
        !            41: 
        !            42: 
        !            43: # A TEST SUITE??? You've got to be kidding!!! LonCAPA don't have no
        !            44: # TEST SUITEs!!!
        !            45: #
        !            46: # Well lontable does and this is it.  The test suite ensures that
        !            47: # the lontable.pm module is able to create the data structures it
        !            48: # purports to create.  The suite also ensures that the correct
        !            49: # information is passed ot the LaTeX::Table class at generate
        !            50: # time.
        !            51: #
        !            52: 
        !            53: use strict;
        !            54: use lontable;
        !            55: use Test::More tests=>18;
        !            56: 
        !            57: #------------------- Default Construction tests: ---------------------------------
        !            58: #  Tests the getter forms of the configuration methods too:
        !            59: 
        !            60: my $testobject = new Apache::lontable();
        !            61: ok(($testobject->alignment() eq 'left'), "Default Construction - Correct alignment");
        !            62: ok(($testobject->table_border() == 0),   "Default Construction - Correct table border");
        !            63: ok(($testobject->cell_border()  == 0),   "Default Construction - Correct cell border");
        !            64: ok(($testobject->caption()  eq ''),      "Default Construction - Correct caption");
        !            65: ok(($testobject->theme() eq "Zurich"),   "Default Construction - Correct theme");
        !            66: ok(($testobject->get_object_attribute('column_count') == 0),
        !            67:                                          "Default Construction - zero columncount");
        !            68: ok((!$testobject->get_object_attribute('row_open')), 
        !            69:                                          "Default Construction - Row not open");
        !            70: my $rows = $testobject->get_object_attribute('rows');
        !            71: ok((scalar(@$rows) == 0),                'Default Construction - empty row array');
        !            72: 
        !            73: 
        !            74: #--------------- Configured construction tests -----------------------------------
        !            75: #
        !            76: 
        !            77: my $testobject = new Apache::lontable({alignment    => 'right',
        !            78: 				       outer_border => 1,
        !            79: 				       inner_border => 1,
        !            80: 				       caption      => 'Test caption',
        !            81: 				       theme        => 'Houston'});
        !            82: ok($testobject->alignment() eq 'right',  'Configured Construction - Correct alignment');
        !            83: ok($testobject->table_border() == 1,     'Configured Construction - correct border');
        !            84: ok($testobject->cell_border() == 1,      'Configured Construction - correct cell border');
        !            85: ok($testobject->caption eq 'Test caption', 'Configured Construction - Correct caption');
        !            86: ok($testobject->theme() eq 'Houston',    'Confiugred construction - correct theme');
        !            87: 
        !            88: 
        !            89: #-------------- Test global configuration setters ----------------------------
        !            90: 
        !            91: # Each test starts with a fresh object:
        !            92: 
        !            93: # Table of methods to test...
        !            94: 
        !            95: my @configmethods = ('alignment', 'table_border', 'cell_border', 'caption', 'theme');
        !            96: 
        !            97: # Table of parameters for each method and expected results from the getter
        !            98: 
        !            99: my @values        = ('center', '1', '1', "Testing", 'Miami');
        !           100: my $i = 0;
        !           101: foreach my $method (@configmethods) {
        !           102:     $testobject = new Apache::lontable();
        !           103:     $testobject->$method($values[$i]);
        !           104:     ok($testobject->$method() eq $values[$i], "Global Config: Testing $method as a setter");
        !           105:     $i++;
        !           106: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>