# Copyright (C) 1997 - 2001 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Please email any bugs, comments, and/or additions to this file to: # hamlib-developer@lists.sourceforge.net set TESTBCD "$srcdir/testbcd" # # Here are the tests # # BCD: 44,34,33,22,12 # BCD: 12,22,33,34,44 proc test_bcd { test freq digits bcdle bcdbe } { global TESTBCD set tmp [exec $TESTBCD $freq $digits] set pat ".*Little Endian mode\nFrequency: $freq\nBCD: $bcdle\nResult after recoding: $freq\n\nBig Endian mode\nFrequency: $freq\nBCD: $bcdbe\nResult after recoding: $freq$" if [regexp $pat $tmp] { pass "$test" } else { clone_output "Expected le: $bcdle, be: $bcdbe, got:\n$tmp" fail "$test" } } test_bcd "10/10 digits" 1222333444 10 "44,34,33,22,12" "12,22,33,34,44" test_bcd "9/10 digits" 999666333 10 "33,63,66,99,09" "09,99,66,63,33" test_bcd "8/10 digits" 87666333 10 "33,63,66,87,00" "00,87,66,63,33" test_bcd "1/10 digit" 1 10 "01,00,00,00,00" "00,00,00,00,01" # note the 10th digit which is undefined test_bcd "9/9 digits" 999666333 9 "33,63,66,99,.9" "99,96,66,33,3." test_bcd "8/9 digits" 87666333 9 "33,63,66,87,.0" "08,76,66,33,3." test_bcd "1/9 digit" 1 9 "01,00,00,00,.0" "00,00,00,00,1."