File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,12 @@ open class Tag {
2121 self . node = Self . createNode ( )
2222 self . children = children
2323 }
24-
24+
25+ /// initialize a new Tag with a single child tag
26+ public convenience init ( _ child: Tag ) {
27+ self . init ( [ child] )
28+ }
29+
2530 /// initialize a new Tag with children using a builder
2631 public convenience init ( @TagBuilder _ builder: ( ) -> [ Tag ] ) {
2732 self . init ( builder ( ) )
Original file line number Diff line number Diff line change 1+ //
2+ // File.swift
3+ //
4+ //
5+ // Created by Tibor Bodecs on 2022. 02. 24..
6+ //
7+
8+ import XCTest
9+ @testable import SwiftSgml
10+
11+ final class TagTests : XCTestCase {
12+
13+ func testConvenienceSingleTagInit( ) {
14+
15+ let doc = Document {
16+ Root ( Leaf ( " hello " ) )
17+ }
18+
19+ XCTAssertEqual ( DocumentRenderer ( ) . render ( doc) , """
20+ <root>
21+ <leaf>hello</leaf>
22+ </root>
23+ """ )
24+ }
25+
26+ }
You can’t perform that action at this time.
0 commit comments