             }
         }
     }
+    
+    func testPDFSurface() {
+        
+        let testName = "testPDFSurface"
+        
+        func fileName(for size: Int) -> String {
+            
+            return outputDirectory + "\(testName)_\(size).pdf"
+        }
+        
+        testDraw(createSurface:{ try! Surface.PDF(filename: fileName(for: $0), width: Double($0), height: Double($0)) }) { (surface) in
+            
+            surface.flush()
+            surface.finish()
+            
+            
+            
+            print("Wrote \(#function) test to \(testFilename)")
+        }
+    }
 }
 
 fileprivate extension Context {

        try! FileManager.default.createDirectory(atPath: outputDirectory, withIntermediateDirectories: false)
    }
    
    // remove all files in directory
    let contents = try! FileManager.default.contentsOfDirectory(atPath: outputDirectory)
    
    contents.forEach { try! FileManager.default.removeItem(atPath: outputDirectory + $0) }


fileprivate extension CairoTests {
    
    func testDraw<T: Surface>(functionName: String = #function,
                  createSurface: (_ size: Int) -> (T),
                  forEach: ((_ surface: T) -> ())? = nil) {
        
        let sizes = [10, 20, 50, 100, 200, 500, 1000, 10000]
        
        for size in sizes {
            
            let surface = createSurface(size)
            
            let context = Cairo.Context(surface: surface)
            
            context.drawSourceX(size: size)
            
            forEach?(surface)
        }
    }
    
    func writeTestPNG(testName: String,
                      functionName: String = #function,
                      forEach: ((_ surface: Surface.Image, _ filename: String) -> ())? = nil) {
