#! /usr/bin/env python # def caesar_test ( ): #*****************************************************************************80 # ## CAESAR_TEST tests the CAESAR library. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 30 January 2016 # # Author: # # John Burkardt # import platform from s_to_caesar import s_to_caesar print ( '' ) print ( 'CAESAR_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' Test the CAESAR library.' ) # # Test 1 # print ( '' ) print ( ' S2 = S_TO_CAESAR ( S1, K ), varying K.' ) print ( '' ) print ( ' K ---------------S1---------------- ---------------S2----------------' ) print ( '' ) for k in range ( -5, 6 ): s1 = 'A man, a plan, a canal: Panama!' s2 = s_to_caesar ( s1, k ) print ( ' %2d "%s" "%s"' % ( k, s1, s2 ) ) # # Test 2 # print ( '' ) print ( ' S2 = S_TO_CAESAR ( S1, K ).' ) print ( ' S3 = S_TO_CAESAR ( S2, -K )' ) print ( '' ) print ( ' K ------------S1------------ ------------S2------------ ------------S3------------' ) print ( '' ) for k in range ( -5, 6 ): s1 = 'The key is under the mat' s2 = s_to_caesar ( s1, k ) s3 = s_to_caesar ( s2, -k ) print ( ' %2d "%s" "%s" "%s"' % ( k, s1, s2, s3 ) ) # # Test 3 # print ( '' ) print ( ' S2 = S_TO_CAESAR ( S1, K ), varying K.' ) print ( '' ) print ( ' K ---------------S2---------------------------------------------------' ) print ( '' ) for k in range ( 0, 27 ): s1 = 'The only thing we have to fear is fear itself.' s2 = s_to_caesar ( s1, k ) print ( ' %2d "%s"' % ( k, s2 ) ) # # Terminate. # print ( '' ) print ( 'CAESAR_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) caesar_test ( ) timestamp ( )