diff --git a/src/main.zig b/src/main.zig index bca28ce..9a92fda 100644 --- a/src/main.zig +++ b/src/main.zig @@ -47,11 +47,11 @@ pub fn main() !void { if (res.args.encode != 0) { for (res.positionals) |pos| { - const encodedString = try encode(allocator, pos); + const encoded = try encode(allocator, pos); - defer allocator.free(encodedString); + defer allocator.free(encoded); - try stdout.writer().print("{s}", .{encodedString}); + try stdout.writer().print("{s}", .{encoded}); return; } else { @@ -59,10 +59,10 @@ pub fn main() !void { var input = try read_from_stream(allocator, stdin); defer input.deinit(); - const encodedString = try encode(allocator, input.items); - defer allocator.free(encodedString); + const encoded = try encode(allocator, input.items); + defer allocator.free(encoded); - try stdout.writer().print("{s}", .{encodedString}); + try stdout.writer().print("{s}", .{encoded}); return; } @@ -70,15 +70,15 @@ pub fn main() !void { if (res.args.decode != 0) { for (res.positionals) |pos| { - const decodedString = decode(allocator, pos) catch |err| { + const decoded = decode(allocator, pos) catch |err| { std.debug.print("unable to decode string '{s}'\n", .{pos}); return err; }; - defer allocator.free(decodedString); + defer allocator.free(decoded); - try stdout.writer().print("{s}", .{decodedString}); + try stdout.writer().print("{s}", .{decoded}); return; } else { @@ -90,15 +90,15 @@ pub fn main() !void { }; defer input.deinit(); - const decodedString = decode(allocator, input.items) catch |err| { + const decoded = decode(allocator, input.items) catch |err| { std.debug.print("unable to decode string '{s}'\n", .{std.mem.trim(u8, input.items, "\r\n")}); return err; }; - defer allocator.free(decodedString); + defer allocator.free(decoded); - try stdout.writer().print("{s}", .{decodedString}); + try stdout.writer().print("{s}", .{decoded}); return; } @@ -164,21 +164,21 @@ fn decode(allocator: std.mem.Allocator, b64string: []const u8) ![]u8 { test "base64_decode() returns decoded string" { const test_allocator = std.testing.allocator; const base64String = "aGVqIGxrc2pkbGthanNkIGxha3NqZGxramFzZA=="; - const expectedString = "hej lksjdlkajsd laksjdlkjasd"; + const expected = "hej lksjdlkajsd laksjdlkjasd"; - const decodedString = try decode(test_allocator, base64String); - defer test_allocator.free(decodedString); + const decoded = try decode(test_allocator, base64String); + defer test_allocator.free(decoded); - try std.testing.expectEqualStrings(expectedString, decodedString); + try std.testing.expectEqualStrings(expected, decoded); } test "base64_encode() returns encoded string" { const test_allocator = std.testing.allocator; - const expectedEncodedString = "aGVqIGxrc2pkbGthanNkIGxha3NqZGxramFzZA=="; - const string = "hej lksjdlkajsd laksjdlkjasd"; + const expected = "aGVqIGxrc2pkbGthanNkIGxha3NqZGxramFzZA=="; + const input = "hej lksjdlkajsd laksjdlkjasd"; - const encodedString = try encode(test_allocator, string); - defer test_allocator.free(encodedString); + const encoded = try encode(test_allocator, input); + defer test_allocator.free(encoded); - try std.testing.expectEqualStrings(expectedEncodedString, encodedString); + try std.testing.expectEqualStrings(expected, encoded); }