foxy_test_add_attributes Program

Uses

  • program~~foxy_test_add_attributes~~UsesGraph program~foxy_test_add_attributes foxy_test_add_attributes module~foxy foxy program~foxy_test_add_attributes->module~foxy module~foxy_xml_file foxy_xml_file module~foxy->module~foxy_xml_file module~foxy_xml_tag foxy_xml_tag module~foxy->module~foxy_xml_tag penf penf module~foxy->penf module~foxy_xml_file->module~foxy_xml_tag module~foxy_xml_file->penf module~foxy_xml_tag->penf stringifor stringifor module~foxy_xml_tag->stringifor

FoXy test.


Calls

program~~foxy_test_add_attributes~~CallsGraph program~foxy_test_add_attributes foxy_test_add_attributes none~add_attributes xml_tag%add_attributes program~foxy_test_add_attributes->none~add_attributes proc~stringify xml_tag%stringify program~foxy_test_add_attributes->proc~stringify proc~add_multiple_attributes xml_tag%add_multiple_attributes none~add_attributes->proc~add_multiple_attributes proc~add_single_attribute xml_tag%add_single_attribute none~add_attributes->proc~add_single_attribute proc~add_stream_attributes xml_tag%add_stream_attributes none~add_attributes->proc~add_stream_attributes chars chars proc~stringify->chars is_allocated is_allocated proc~stringify->is_allocated proc~end_tag xml_tag%end_tag proc~stringify->proc~end_tag proc~self_closing_tag xml_tag%self_closing_tag proc~stringify->proc~self_closing_tag proc~start_tag xml_tag%start_tag proc~stringify->proc~start_tag proc~add_multiple_attributes->proc~add_single_attribute proc~alloc_attributes xml_tag%alloc_attributes proc~add_single_attribute->proc~alloc_attributes proc~add_stream_attributes->proc~add_single_attribute fill fill proc~add_stream_attributes->fill partition partition proc~add_stream_attributes->partition slice slice proc~add_stream_attributes->slice

Variables

Type Attributes Name Initial
character(len=:), allocatable :: source

String containing the source XML data.

character(len=:), allocatable :: parsed

String containing the parsed XML data.

type(xml_tag) :: a_tag

XML tag handler.

logical :: test_passed(3)

List of passed tests.


Source Code

program foxy_test_add_attributes
!< FoXy test.
use foxy, only: xml_file, xml_tag

implicit none
character(len=:), allocatable :: source         !< String containing the source XML data.
character(len=:), allocatable :: parsed         !< String containing the parsed XML data.
type(xml_tag)                 :: a_tag          !< XML tag handler.
logical                       :: test_passed(3) !< List of passed tests.

test_passed = .false.

print "(A)", 'source'
source = '<first x="1" y="c" z="2">lorem ipsum...</first>'
print "(A)", source
print "(A)", 'created'
a_tag = xml_tag(name='first', content='lorem ipsum...', attributes=reshape([['x', '1'], ['y', 'c'], ['z', '2']], [2,3]))

parsed = a_tag%stringify()
test_passed(1) = trim(adjustl(source))==trim(adjustl(parsed))
print "(A,L1)", parsed//' Is correct? ', test_passed(1)

call a_tag%add_attributes(attributes_stream='y="3" a="one" b = "two" cc="tree"')
print "(A)", 'source'
source = '<first x="1" y="3" z="2" a="one" b="two" cc="tree">lorem ipsum...</first>'
print "(A)", source
print "(A)", 'created'
parsed = a_tag%stringify()
test_passed(2) = trim(adjustl(source))==trim(adjustl(parsed))
print "(A,L1)", parsed//' Is correct? ', test_passed(2)

call a_tag%add_attributes(attributes_stream='')
print "(A)", 'source'
source = '<first x="1" y="3" z="2" a="one" b="two" cc="tree">lorem ipsum...</first>'
print "(A)", source
print "(A)", 'created'
parsed = a_tag%stringify()
test_passed(3) = trim(adjustl(source))==trim(adjustl(parsed))
print "(A,L1)", parsed//' Is correct? ', test_passed(3)

print "(A,L1)", new_line('a')//'Are all tests passed? ', all(test_passed)
endprogram foxy_test_add_attributes