|
| 1 | +const std = @import("std"); |
| 2 | +const testing = std.testing; |
| 3 | + |
| 4 | +const micro_blog = @import("micro_blog.zig"); |
| 5 | + |
| 6 | +test "English language short" { |
| 7 | + const expected: []const u8 = "Hi"; |
| 8 | + const actual = micro_blog.truncate("Hi"); |
| 9 | + try testing.expectEqualStrings(expected, actual); |
| 10 | +} |
| 11 | + |
| 12 | +test "English language long" { |
| 13 | + const expected: []const u8 = "Hello"; |
| 14 | + const actual = micro_blog.truncate("Hello there"); |
| 15 | + try testing.expectEqualStrings(expected, actual); |
| 16 | +} |
| 17 | + |
| 18 | +test "German language short (broth)" { |
| 19 | + const expected: []const u8 = "brühe"; |
| 20 | + const actual = micro_blog.truncate("brühe"); |
| 21 | + try testing.expectEqualStrings(expected, actual); |
| 22 | +} |
| 23 | + |
| 24 | +test "German language long (bear carpet → beards)" { |
| 25 | + const expected: []const u8 = "Bärte"; |
| 26 | + const actual = micro_blog.truncate("Bärteppich"); |
| 27 | + try testing.expectEqualStrings(expected, actual); |
| 28 | +} |
| 29 | + |
| 30 | +test "Bulgarian language short (good)" { |
| 31 | + const expected: []const u8 = "Добър"; |
| 32 | + const actual = micro_blog.truncate("Добър"); |
| 33 | + try testing.expectEqualStrings(expected, actual); |
| 34 | +} |
| 35 | + |
| 36 | +test "Greek language short (health)" { |
| 37 | + const expected: []const u8 = "υγειά"; |
| 38 | + const actual = micro_blog.truncate("υγειά"); |
| 39 | + try testing.expectEqualStrings(expected, actual); |
| 40 | +} |
| 41 | + |
| 42 | +test "Maths short" { |
| 43 | + const expected: []const u8 = "a=πr²"; |
| 44 | + const actual = micro_blog.truncate("a=πr²"); |
| 45 | + try testing.expectEqualStrings(expected, actual); |
| 46 | +} |
| 47 | + |
| 48 | +test "Maths long" { |
| 49 | + const expected: []const u8 = "∅⊊ℕ⊊ℤ"; |
| 50 | + const actual = micro_blog.truncate("∅⊊ℕ⊊ℤ⊊ℚ⊊ℝ⊊ℂ"); |
| 51 | + try testing.expectEqualStrings(expected, actual); |
| 52 | +} |
| 53 | + |
| 54 | +test "English and emoji short" { |
| 55 | + const expected: []const u8 = "Fly 🛫"; |
| 56 | + const actual = micro_blog.truncate("Fly 🛫"); |
| 57 | + try testing.expectEqualStrings(expected, actual); |
| 58 | +} |
| 59 | + |
| 60 | +test "Emoji short" { |
| 61 | + const expected: []const u8 = "💇"; |
| 62 | + const actual = micro_blog.truncate("💇"); |
| 63 | + try testing.expectEqualStrings(expected, actual); |
| 64 | +} |
| 65 | + |
| 66 | +test "Emoji long" { |
| 67 | + const expected: []const u8 = "❄🌡🤧🤒🏥"; |
| 68 | + const actual = micro_blog.truncate("❄🌡🤧🤒🏥🕰😀"); |
| 69 | + try testing.expectEqualStrings(expected, actual); |
| 70 | +} |
| 71 | + |
| 72 | +test "Royal Flush?" { |
| 73 | + const expected: []const u8 = "🃎🂸🃅🃋🃍"; |
| 74 | + const actual = micro_blog.truncate("🃎🂸🃅🃋🃍🃁🃊"); |
| 75 | + try testing.expectEqualStrings(expected, actual); |
| 76 | +} |
| 77 | + |
| 78 | +test "ideograms" { |
| 79 | + const expected: []const u8 = "二兎を追う"; |
| 80 | + const actual = micro_blog.truncate("二兎を追う者は一兎をも得ず"); |
| 81 | + try testing.expectEqualStrings(expected, actual); |
| 82 | +} |
0 commit comments