From 704861215f786c2189335713b7d211ac2837e2ad Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 11 May 2025 01:24:47 -0700 Subject: [PATCH] conform to ziginfra --- build.zig | 22 ++++++++++++++++++++++ licenses.txt | 3 +++ mod.zig | 19 ------------------- test.zig | 21 +++++++++++++++++++++ 4 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 build.zig create mode 100644 licenses.txt create mode 100644 test.zig diff --git a/build.zig b/build.zig new file mode 100644 index 0000000000000000000000000000000000000000..629f32099d91efb146e1f88465f3060f00f2f4cc --- /dev/null +++ b/build.zig @@ -0,0 +1,22 @@ +const std = @import("std"); +const deps = @import("./deps.zig"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; + const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; + + const tests = b.addTest(.{ + .root_source_file = b.path("test.zig"), + .target = target, + .optimize = mode, + }); + deps.addAllTo(tests); + tests.use_llvm = !disable_llvm; + tests.use_lld = !disable_llvm; + + const test_step = b.step("test", "Run all library tests"); + const tests_run = b.addRunArtifact(tests); + tests_run.has_side_effects = true; + test_step.dependOn(&tests_run.step); +} diff --git a/licenses.txt b/licenses.txt new file mode 100644 index 0000000000000000000000000000000000000000..6336b470e0dc9933d1fad883c84eaf86174573d6 --- /dev/null +++ b/licenses.txt @@ -0,0 +1,3 @@ +MIT: += https://spdx.org/licenses/MIT +- This diff --git a/mod.zig b/mod.zig index 1a5909d27ef9fb2dff7a6283be85194f4522f9bc..d7ee49a08a1911c5bb740184ef98c73f1d0ee6eb 100644 --- a/mod.zig +++ b/mod.zig @@ -30,22 +30,3 @@ pub fn lookup(entity: []const u8) ?Entity { } return null; } - -test "entities" { - try testing.expectEqual(@as(usize, 2231), ENTITIES.len); - - const aelig = lookup("Æ").?; - try testing.expectEqualStrings("Æ", aelig.entity); - try testing.expectEqual(Codepoints{ .Single = 198 }, aelig.codepoints); - try testing.expectEqualStrings("Æ", aelig.characters); - - const afr = lookup("𝔄").?; - try testing.expectEqualStrings("𝔄", afr.entity); - try testing.expectEqual(Codepoints{ .Single = 120068 }, afr.codepoints); - try testing.expectEqualStrings("𝔄", afr.characters); - - const bnequiv = lookup("≡⃥").?; - try testing.expectEqualStrings("≡⃥", bnequiv.entity); - try testing.expectEqual(Codepoints{ .Double = [2]u32{ 8801, 8421 } }, bnequiv.codepoints); - try testing.expectEqualStrings("\u{2261}\u{20E5}", bnequiv.characters); -} diff --git a/test.zig b/test.zig new file mode 100644 index 0000000000000000000000000000000000000000..5bf6bfe0808c66195021df8c3f84120b8145e517 --- /dev/null +++ b/test.zig @@ -0,0 +1,21 @@ +const std = @import("std"); +const htmlentities = @import("htmlentities"); + +test { + try std.testing.expectEqual(@as(usize, 2231), htmlentities.ENTITIES.len); + + const aelig = htmlentities.lookup("Æ").?; + try std.testing.expectEqualStrings("Æ", aelig.entity); + try std.testing.expectEqual(htmlentities.Codepoints{ .Single = 198 }, aelig.codepoints); + try std.testing.expectEqualStrings("Æ", aelig.characters); + + const afr = htmlentities.lookup("𝔄").?; + try std.testing.expectEqualStrings("𝔄", afr.entity); + try std.testing.expectEqual(htmlentities.Codepoints{ .Single = 120068 }, afr.codepoints); + try std.testing.expectEqualStrings("𝔄", afr.characters); + + const bnequiv = htmlentities.lookup("≡⃥").?; + try std.testing.expectEqualStrings("≡⃥", bnequiv.entity); + try std.testing.expectEqual(htmlentities.Codepoints{ .Double = [2]u32{ 8801, 8421 } }, bnequiv.codepoints); + try std.testing.expectEqualStrings("\u{2261}\u{20E5}", bnequiv.characters); +} -- 2.54.0