uf @ 40a544bac1f8799d40df377a90fb89d24fc2803c

test: Add testing

Also add blank space between line being merged together.
diff --git a/src/main.zig b/src/main.zig
index 14eb65c02af62dcd3f90b6228567a2fd7bc5e6e2..21103fff4a11308d5167d9b708f5ff80fc668808 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,11 +1,12 @@
 const std = @import("std");
 const File = std.fs.File;
+const Reader = std.fs.File.Reader;
 const Writer = std.fs.File.Writer;
 
 pub fn main() !void {
     const in = std.io.getStdIn();
     const out = std.io.getStdOut();
-    Uf.init().streamCopy(in, out) catch |err| {
+    Uf.init().streamCopy(in.reader(), out.writer()) catch |err| {
         try std.io.getStdErr().writer().print("Error {}", .{err});
     };
 }
@@ -22,12 +23,12 @@     fn init() Self {
         return Self{};
     }
 
-    fn flush(_: Self, out: Writer) !void {
+    fn flush(_: Self, out: anytype) !void {
         _ = try out.write(out_buf[0..out_index]);
         out_index = 0;
     }
 
-    fn writeChar(self: Self, out: Writer, c: u8) !void {
+    fn writeChar(self: Self, out: anytype, c: u8) !void {
         if (out_index >= buf_size) {
             try self.flush(out);
         }
@@ -35,10 +36,7 @@         out_buf[out_index] = c;
         out_index += 1;
     }
 
-    fn streamCopy(self: Self, in: File, out: File) !void {
-        const reader = in.reader();
-        const writer = out.writer();
-
+    fn streamCopy(self: Self, reader: anytype, writer: anytype) !void {
         var hit = false;
         var second = false;
         var in_buf: [buf_size]u8 = undefined;
@@ -55,6 +53,8 @@                     }
                 } else if (hit and c != '\n') {
                     if (second) {
                         try self.writeChar(writer, '\n');
+                    } else {
+                        try self.writeChar(writer, ' ');
                     }
                     hit = false;
                     second = false;
@@ -73,3 +73,32 @@             }
         }
     }
 };
+
+test "Test format" {
+    const text_in =
+        \\# This is a markdown
+        \\
+        \\Lorem ipsum dolor sit amet,
+        \\consectetur adipiscing elit.
+        \\
+        \\
+        \\
+        \\Praesent pharetra sit amet ante sit amet consequat.
+    ;
+
+    const text_out =
+        \\# This is a markdown
+        \\
+        \\Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+        \\
+        \\Praesent pharetra sit amet ante sit amet consequat.
+    ;
+
+    var stream = std.io.fixedBufferStream(text_in);
+
+    var list = std.ArrayList(u8).init(std.testing.allocator);
+    defer list.deinit();
+
+    try Uf.init().streamCopy(stream.reader(), list.writer());
+    try std.testing.expect(std.mem.eql(u8, text_out, list.items));
+}