testText_prg Program

program~~testtext_prg~~UsesGraph program~testtext_prg testText_prg module~kinds_mod kinds_mod module~kinds_mod->program~testtext_prg module~text_mod text_mod module~kinds_mod->module~text_mod module~time_mod time_mod module~kinds_mod->module~time_mod module~text_mod->program~testtext_prg module~time_mod->module~text_mod iso_fortran_env iso_fortran_env iso_fortran_env->module~text_mod iso_c_binding iso_c_binding iso_c_binding->module~time_mod
Help


Test program for text_mod

Calls

program~~testtext_prg~~CallsGraph program~testtext_prg testText_prg proc~testcolormap testColorMap program~testtext_prg->proc~testcolormap proc~testinttochar testIntToChar program~testtext_prg->proc~testinttochar proc~teststartswith testStartsWith program~testtext_prg->proc~teststartswith proc~testendswith testEndsWith program~testtext_prg->proc~testendswith proc~testremovespaces testRemoveSpaces program~testtext_prg->proc~testremovespaces proc~testcolorize testColorize program~testtext_prg->proc~testcolorize proc~testrealtochar testRealToChar program~testtext_prg->proc~testrealtochar proc~testrealtotime testRealToTime program~testtext_prg->proc~testrealtotime proc~colormap colorMap proc~testcolormap->proc~colormap proc~inttochar intToChar proc~testinttochar->proc~inttochar proc~startswith startsWith proc~teststartswith->proc~startswith proc~endswith endsWith proc~testendswith->proc~endswith proc~removespaces removeSpaces proc~testremovespaces->proc~removespaces proc~colorize colorize proc~testcolorize->proc~colorize proc~realtochar realToChar proc~testrealtochar->proc~realtochar proc~realtotime realToTime proc~testrealtotime->proc~realtotime proc~colorize->proc~inttochar proc~realtotime->proc~inttochar
Help

Source Code


Subroutines

subroutine testRemoveSpaces()

Test removeSpaces to verify operation

Arguments

None

subroutine testStartsWith()

Test startsWith to verify operation

Arguments

None

subroutine testEndsWith()

Test endsWith to verify operation

Arguments

None

subroutine testIntToChar()

Test intToChar to verify operation

Arguments

None

subroutine testRealToChar()

Test realToChar to verify operation

Arguments

None

subroutine testRealToTime()

Test realToTime to verify operation

Arguments

None

subroutine testColorize()

Test colorize to verify operation

Arguments

None

subroutine testColorMap()

Test colorMap to verify operation

Arguments

None

Source Code

program testText_prg
	!! Test program for text_mod
	use kinds_mod
	use text_mod
	implicit none
	
	call testRemoveSpaces
	
	call testStartsWith
	call testEndsWith
	
	call testIntToChar
	call testRealToChar
	call testRealToTime
	
	call testColorize
	call testColorMap
	
contains

	subroutine testRemoveSpaces
		!! Test removeSpaces to verify operation
		!! @todo
		!! Make me a test with stop conditions
		character(:),allocatable::s1,s2
		
		s1 = 'This Is A Test'
		s2 = removeSpaces(s1)
		
		write(*,*) '|'//s2//'|'
	end subroutine testRemoveSpaces

	subroutine testStartsWith
		!! Test startsWith to verify operation
		logical,dimension(4)::results
		
		results(1) = startsWith('thisFunction','this')
		results(2) = .not.startsWith('thisFunction','that')
		results(3) = .not.startsWith('','this')
		results(4) = startsWith('thisFunction','')
		
		if( .not.all(results) ) error stop "Failed startsWith check"
	end subroutine testStartsWith

	subroutine testEndsWith
		!! Test endsWith to verify operation
		logical,dimension(4)::results
		
		results(1) = endsWith('thisFunction','Function')
		results(2) = .not.endsWith('thisFunction','Subroutine')
		results(3) = .not.endsWith('','this')
		results(4) = endsWith('thisFunction','')
		
		if( .not.all(results) ) error stop "Failed endsWith check"
	end subroutine testEndsWith

	subroutine testIntToChar
		!! Test intToChar to verify operation
		logical,dimension(4)::results
		
		results(1) = intToChar(1)=='1'
		results(2) = intToChar(-1)=='-1'
		results(3) = intToChar(1,'(1I4.4)')=='0001'
		results(4) = intToChar(1,'(1I4.4)',6)=='0001  '
		
		if( .not.all(results) ) error stop "Failed intToChar check"
	end subroutine testIntToChar

	subroutine testRealToChar
		!! Test realToChar to verify operation
		logical,dimension(2)::results
		
		results(1) = realToChar(1.0_wp,'(1F10.5)')=='1.00000'
		results(2) = realToChar(1.0_wp,'(1F10.5)',20)=='1.00000             '
		
		if( .not.all(results) ) error stop "Failed realToChar check"
	end subroutine testRealToChar

	subroutine testRealToTime
		!! Test realToTime to verify operation
		logical,dimension(1)::results
		
		results(1) = realToTime(3600.0_wp*24.0_wp+3600.0_wp*2.0_wp+60.0_wp*3.0_wp+4.0_wp)=='1d 2h 3m 4s'
		
		if( .not.all(results) ) error stop "Failed realToTime check"
	end subroutine testRealToTime

	subroutine testColorize
		!! Test colorize to verify operation
		character(:),allocatable::test,true
		
		character(1),parameter::ESC = achar(27)
		
		test = colorize('white',[5,5,5])
		true = ESC//'[38;5;'//'231'//'m'//'white'//ESC//'[0m'
		
		if( .not.(test==true) ) error stop "Failed colorize check"
	end subroutine testColorize

	subroutine testColorMap
		!! Test colorMap to verify operation
		integer,parameter::N = 11
		integer,dimension(N,3),parameter::true = & 
			& reshape([ 0,1,2,3,4,5,5,5,5,5,5, &
			&           0,1,2,3,4,5,4,3,2,1,0, &
			&           5,5,5,5,5,5,4,3,2,1,0 ],[N,3])
		real(wp),dimension(2),parameter::R = [0.0_wp,1.0_wp]
		
		integer,dimension(N,3)::test
		real(wp)::x
		integer::k
		
		do k=1,N
			x = real(k-1,wp)/real(N-1,wp)
			test(k,1:3) = colorMap(x,R)
		end do
		
		if( .not.all(true==test) ) error stop "Failed colorMap check"
	end subroutine testColorMap

end program testText_prg