StringiFor equal test.
!< StringiFor `equal` test. program equal !----------------------------------------------------------------------------------------------------------------------------------- !< StringiFor `equal` test. !----------------------------------------------------------------------------------------------------------------------------------- use, intrinsic :: iso_fortran_env, only : stdout => output_unit use stringifor, only : string !----------------------------------------------------------------------------------------------------------------------------------- !----------------------------------------------------------------------------------------------------------------------------------- implicit none type(string) :: astring !< A string. type(string) :: anotherstring !< A string. character(len=:), allocatable :: acharacter !< A character. logical :: test_passed(6) !< List of passed tests. !----------------------------------------------------------------------------------------------------------------------------------- !----------------------------------------------------------------------------------------------------------------------------------- test_passed = .false. astring = ' one ' anotherstring = 'two' acharacter = 'three' test_passed(1) = ((astring==anotherstring).eqv..false.) write(stdout, "(A,L1)") 'Test "'//astring//'=='//anotherstring//'", test passed? ', test_passed(1) test_passed(2) = ((astring==acharacter).eqv..false.) write(stdout, "(A,L1)") 'Test "'//astring//'=='//acharacter//'", test passed? ', test_passed(2) test_passed(3) = ((acharacter==astring).eqv..false.) write(stdout, "(A,L1)") 'Test "'//acharacter//'=='//astring//'", test passed? ', test_passed(3) astring = 'the same ' anotherstring = 'the same ' acharacter = 'the same ' test_passed(4) = ((astring==anotherstring).eqv..true.) write(stdout, "(A,L1)") 'Test "'//astring//'=='//anotherstring//'", test passed? ', test_passed(4) test_passed(5) = ((astring==acharacter).eqv..true.) write(stdout, "(A,L1)") 'Test "'//astring//'=='//acharacter//'", test passed? ', test_passed(5) test_passed(6) = ((acharacter==astring).eqv..true.) write(stdout, "(A,L1)") 'Test "'//acharacter//'=='//astring//'", test passed? ', test_passed(6) write(stdout, "(A,L1)") new_line('a')//'Are all tests passed? ', all(test_passed) stop !----------------------------------------------------------------------------------------------------------------------------------- endprogram equal