             // Person is a class with multiple fields.
             let person = Person.testValue
             _testRoundTrip(of: person, expectedYAML: "name: Johnny Appleseed\nemail: appleseed@apple.com\n")
+        }
+
+        func testEncodingTopLevelStructuredSingleStruct() {
+            // Numbers is a struct which encodes as an array through a single value container.
+            let numbers = Numbers.testValue
+            _testRoundTrip(of: numbers, expectedYAML: "- 4\n- 8\n- 15\n- 16\n- 23\n- 42\n")
+        }
+
+        func testEncodingTopLevelStructuredSingleClass() {
+            // Mapping is a class which encodes as a dictionary through a single value container.
+            let mapping = Mapping.testValue
+            _testRoundTrip(of: mapping, expectedYAML: """
+                Apple:
+                  relative: http://apple.com
+                localhost:
+                  relative: http://127.0.0.1
+
+                """)
         }
 
         func testEncodingTopLevelDeepStructuredType() {


    // MARK: - Single-Value Types
    /// A simple on-off switch type that encodes as a single Bool value.
    fileprivate enum Switch: Codable {
        case off
        case on // swiftlint:disable:this identifier_name

        init(from decoder: Decoder) throws {
            let container = try decoder.singleValueContainer()

        #endif
        }

        // MARK: - Encoder Features
        func testNestedContainerCodingPaths() {
            let encoder = YAMLEncoder()
            do {
                _ = try encoder.encode(NestedContainersTestType())
            } catch {
                expectUnreachable("Caught error during encoding nested container types: \(error)")
            }
        }

        func testSuperEncoderCodingPaths() {
            let encoder = YAMLEncoder()
            do {
                _ = try encoder.encode(NestedContainersTestType(testSuperEncoder: true))
            } catch {
                expectUnreachable("Caught error during encoding nested container types: \(error)")
            }
        }

        func testInterceptDecimal() {
            let expectedYAML = "value: 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n"

            // Want to make sure we write out a YAML number, not the keyed encoding here.
            // 1e127 is too big to fit natively in a Double, too, so want to make sure it's encoded as a Decimal.
            let decimal = Decimal(sign: .plus, exponent: 127, significand: Decimal(1))
            _testRoundTrip(of: TopLevelWrapper(decimal), expectedYAML: expectedYAML)

            // Optional Decimals should encode the same way.
            // FIXME: following test is blocked by https://bugs.swift.org/browse/SR-5206
//            _testRoundTrip(of: OptionalTopLevelWrapper(decimal), expectedYAML: expectedYAML)
        }

        func testInterceptURL() {
            // Want to make sure YAMLEncoder writes out single-value URLs, not the keyed encoding.
            let expectedYAML = "value: http://swift.org\n"
            let url = URL(string: "http://swift.org")!
            _testRoundTrip(of: TopLevelWrapper(url), expectedYAML: expectedYAML)

            // Optional URLs should encode the same way.
            // FIXME: following test is blocked by https://bugs.swift.org/browse/SR-5206
//            _testRoundTrip(of: OptionalTopLevelWrapper(url), expectedYAML: expectedYAML)
        }

        // MARK: - Helper Functions
        private func _testEncodeFailure<T: Encodable>(of value: T) {
            do {
                _ = try JSONEncoder().encode(value)
                expectUnreachable("Encode of top-level \(T.self) was expected to fail.")
            } catch {}
        }

        private func _testRoundTrip<T>(of value: T,
                                       expectedYAML yamlString: String? = nil,
                                       file: StaticString = #file,
