@@ -21,3 +21,35 @@ def test_last_attribute(init_rapidxml):
2121 attr2 = test .last_attribute ("attr2" )
2222 assert attr2 .name == "attr2"
2323 assert attr2 .value == "two"
24+
25+ def test_append_attribute (init_rapidxml ):
26+ root = init_rapidxml .first_node ()
27+ root .append_attribute (init_rapidxml .allocate_attribute ())
28+ assert root .last_attribute ().name == ""
29+ assert root .last_attribute ().value == ""
30+ root .append_attribute (init_rapidxml .allocate_attribute ("test" ))
31+ assert root .last_attribute ().name == "test"
32+ assert root .last_attribute ().value == ""
33+ root .append_attribute (init_rapidxml .allocate_attribute (value = "test" ))
34+ assert root .last_attribute ().name == ""
35+ assert root .last_attribute ().value == "test"
36+ root .append_attribute (init_rapidxml .allocate_attribute ("test" , "test" ))
37+ assert root .last_attribute ().name == "test"
38+ assert root .last_attribute ().value == "test"
39+
40+ def test_prepend_attribute (init_rapidxml ):
41+ root = init_rapidxml .first_node ()
42+ root .prepend_attribute (init_rapidxml .allocate_attribute ("test" , "test" ))
43+ assert root .first_attribute ().name == "test"
44+ assert root .first_attribute ().value == "test"
45+ root .prepend_attribute (init_rapidxml .allocate_attribute ("test2" , "test2" ))
46+ assert root .first_attribute ().name == "test2"
47+ assert root .first_attribute ().value == "test2"
48+
49+ def test_insert_attribute (init_rapidxml ):
50+ test = init_rapidxml .first_node ().first_node ()
51+ attr2 = test .first_attribute ("attr2" )
52+ test .insert_attribute (attr2 , init_rapidxml .allocate_attribute ("test" , "test" ))
53+ test = attr2 .previous_attribute ()
54+ assert test .name == "test"
55+ assert test .value == "test"
0 commit comments