     }
 }
 
-struct NestedContainersTestType : Encodable {
-    let testSuperEncoder: Bool
-    
-    init(testSuperEncoder: Bool = false) {
-        self.testSuperEncoder = testSuperEncoder
-    }
-    
-    enum TopLevelCodingKeys : Int, CodingKey {
-        case a
-        case b
-        case c
-    }
-    
-    enum IntermediateCodingKeys : Int, CodingKey {
-        case one
-        case two
-    }
-    
-    func encode(to encoder: Encoder) throws {
-        if self.testSuperEncoder {
-            var topLevelContainer = encoder.container(keyedBy: TopLevelCodingKeys.self)
-            expectEqualPaths(encoder.codingPath, [], "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(topLevelContainer.codingPath, [], "New first-level keyed container has non-empty codingPath.")
-            
-            let superEncoder = topLevelContainer.superEncoder(forKey: .a)
-            expectEqualPaths(encoder.codingPath, [], "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(topLevelContainer.codingPath, [], "First-level keyed container's codingPath changed.")
-            expectEqualPaths(superEncoder.codingPath, [TopLevelCodingKeys.a], "New superEncoder had unexpected codingPath.")
-            _testNestedContainers(in: superEncoder, baseCodingPath: [TopLevelCodingKeys.a])
-        } else {
-            _testNestedContainers(in: encoder, baseCodingPath: [])
-        }
-    }
-    
-    func _testNestedContainers(in encoder: Encoder, baseCodingPath: [CodingKey]) {
-        expectEqualPaths(encoder.codingPath, baseCodingPath, "New encoder has non-empty codingPath.")
-        
-        // codingPath should not change upon fetching a non-nested container.
-        var firstLevelContainer = encoder.container(keyedBy: TopLevelCodingKeys.self)
-        expectEqualPaths(encoder.codingPath, baseCodingPath, "Top-level Encoder's codingPath changed.")
-        expectEqualPaths(firstLevelContainer.codingPath, baseCodingPath, "New first-level keyed container has non-empty codingPath.")
-        
-        // Nested Keyed Container
-        do {
-            // Nested container for key should have a new key pushed on.
-            var secondLevelContainer = firstLevelContainer.nestedContainer(keyedBy: IntermediateCodingKeys.self, forKey: .a)
-            expectEqualPaths(encoder.codingPath, baseCodingPath, "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(firstLevelContainer.codingPath, baseCodingPath, "First-level keyed container's codingPath changed.")
-            expectEqualPaths(secondLevelContainer.codingPath, baseCodingPath + [TopLevelCodingKeys.a], "New second-level keyed container had unexpected codingPath.")
-            
-            // Inserting a keyed container should not change existing coding paths.
-            let thirdLevelContainerKeyed = secondLevelContainer.nestedContainer(keyedBy: IntermediateCodingKeys.self, forKey: .one)
-            expectEqualPaths(encoder.codingPath, baseCodingPath, "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(firstLevelContainer.codingPath, baseCodingPath, "First-level keyed container's codingPath changed.")
-            expectEqualPaths(secondLevelContainer.codingPath, baseCodingPath + [TopLevelCodingKeys.a], "Second-level keyed container's codingPath changed.")
-            expectEqualPaths(thirdLevelContainerKeyed.codingPath, baseCodingPath + [TopLevelCodingKeys.a, IntermediateCodingKeys.one], "New third-level keyed container had unexpected codingPath.")
-            
-            // Inserting an unkeyed container should not change existing coding paths.
-            let thirdLevelContainerUnkeyed = secondLevelContainer.nestedUnkeyedContainer(forKey: .two)
-            expectEqualPaths(encoder.codingPath, baseCodingPath + [], "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(firstLevelContainer.codingPath, baseCodingPath + [], "First-level keyed container's codingPath changed.")
-            expectEqualPaths(secondLevelContainer.codingPath, baseCodingPath + [TopLevelCodingKeys.a], "Second-level keyed container's codingPath changed.")
-            expectEqualPaths(thirdLevelContainerUnkeyed.codingPath, baseCodingPath + [TopLevelCodingKeys.a, IntermediateCodingKeys.two], "New third-level unkeyed container had unexpected codingPath.")
-        }
-        
-        // Nested Unkeyed Container
-        do {
-            // Nested container for key should have a new key pushed on.
-            var secondLevelContainer = firstLevelContainer.nestedUnkeyedContainer(forKey: .b)
-            expectEqualPaths(encoder.codingPath, baseCodingPath, "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(firstLevelContainer.codingPath, baseCodingPath, "First-level keyed container's codingPath changed.")
-            expectEqualPaths(secondLevelContainer.codingPath, baseCodingPath + [TopLevelCodingKeys.b], "New second-level keyed container had unexpected codingPath.")
-            
-            // Appending a keyed container should not change existing coding paths.
-            let thirdLevelContainerKeyed = secondLevelContainer.nestedContainer(keyedBy: IntermediateCodingKeys.self)
-            expectEqualPaths(encoder.codingPath, baseCodingPath, "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(firstLevelContainer.codingPath, baseCodingPath, "First-level keyed container's codingPath changed.")
-            expectEqualPaths(secondLevelContainer.codingPath, baseCodingPath + [TopLevelCodingKeys.b], "Second-level unkeyed container's codingPath changed.")
-            expectEqualPaths(thirdLevelContainerKeyed.codingPath, baseCodingPath + [TopLevelCodingKeys.b, _TestKey(index: 0)], "New third-level keyed container had unexpected codingPath.")
-            
-            // Appending an unkeyed container should not change existing coding paths.
-            let thirdLevelContainerUnkeyed = secondLevelContainer.nestedUnkeyedContainer()
-            expectEqualPaths(encoder.codingPath, baseCodingPath, "Top-level Encoder's codingPath changed.")
-            expectEqualPaths(firstLevelContainer.codingPath, baseCodingPath, "First-level keyed container's codingPath changed.")
-            expectEqualPaths(secondLevelContainer.codingPath, baseCodingPath + [TopLevelCodingKeys.b], "Second-level unkeyed container's codingPath changed.")
-            expectEqualPaths(thirdLevelContainerUnkeyed.codingPath, baseCodingPath + [TopLevelCodingKeys.b, _TestKey(index: 1)], "New third-level unkeyed container had unexpected codingPath.")
-        }
-    }
-}
-
-/// A key type which can take on any string or integer value.
-/// This needs to mirror _PlistKey.
-fileprivate struct _TestKey : CodingKey {
-    var stringValue: String
-    var intValue: Int?
-    
-    init?(stringValue: String) {
-        self.stringValue = stringValue
-        self.intValue = nil
-    }
-    
-    init?(intValue: Int) {
-        self.stringValue = "\(intValue)"
-        self.intValue = intValue
-    }
-    
-    init(index: Int) {
-        self.stringValue = "Index \(index)"
-        self.intValue = index
-    }
-}
-
 class TestCodableFirestore: XCTestCase {
     
     func testFirebaseEncoder() {

        do {
            let _ = try FirestoreEncoder().encode(value)
            XCTFail("Encode of top-level \(T.self) was expected to fail.")
        } catch {}
    }
    
    private func _testRoundTripTypeCoercionFailure<T,U>(of value: T, as type: U.Type) where T : Codable, U : Codable {
        do {
            let data = try FirestoreEncoder().encode(value)
            let _ = try FirestoreDecoder().decode(U.self, from: data)
            XCTFail("Coercion from \(T.self) to \(U.self) was expected to fail.")
        } catch {}
    }
    

    }
}

/// Wraps a type T so that it can be encoded at the top level of a payload.
struct TopLevelWrapper<T> : Codable, Equatable where T : Codable, T : Equatable {
    enum CodingKeys : String, CodingKey {
