authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-02-14 19:15:09+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-02-14 19:15:09+11:00
log6ea6d5a4bdcf6f37c43857570522ee1308115de7
tree4d6052e4b8073a3f1ea7b836172925f600892772
parentca41567924d0576be9a000076d29ec5f46a93e95
signature Commit is signed but in an unrecognized format.

std: use testing.allocator in tests


5 files changed, 147 insertions(+), 87 deletions(-)

lib/std/json.zig+15-14
...@@ -1598,21 +1598,21 @@ test "write json then parse it" {...@@ -1598,21 +1598,21 @@ test "write json then parse it" {
1598 testing.expect(mem.eql(u8, tree.root.Object.get("str").?.value.String, "hello"));1598 testing.expect(mem.eql(u8, tree.root.Object.get("str").?.value.String, "hello"));
1599}1599}
16001600
1601fn test_parse(memory: []u8, json_str: []const u8) !Value {1601fn test_parse(arena_allocator: *std.mem.Allocator, json_str: []const u8) !Value {
1602 // buf_alloc goes out of scope, but we don't use it after parsing1602 var p = Parser.init(arena_allocator, false);
1603 var buf_alloc = std.heap.FixedBufferAllocator.init(memory);
1604 var p = Parser.init(&buf_alloc.allocator, false);
1605 return (try p.parse(json_str)).root;1603 return (try p.parse(json_str)).root;
1606}1604}
16071605
1608test "parsing empty string gives appropriate error" {1606test "parsing empty string gives appropriate error" {
1609 var memory: [1024 * 4]u8 = undefined;1607 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
1610 testing.expectError(error.UnexpectedEndOfJson, test_parse(&memory, ""));1608 defer arena_allocator.deinit();
1609 testing.expectError(error.UnexpectedEndOfJson, test_parse(&arena_allocator.allocator, ""));
1611}1610}
16121611
1613test "integer after float has proper type" {1612test "integer after float has proper type" {
1614 var memory: [1024 * 8]u8 = undefined;1613 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
1615 const json = try test_parse(&memory,1614 defer arena_allocator.deinit();
1615 const json = try test_parse(&arena_allocator.allocator,
1616 \\{1616 \\{
1617 \\ "float": 3.14,1617 \\ "float": 3.14,
1618 \\ "ints": [1, 2, 3]1618 \\ "ints": [1, 2, 3]
...@@ -1622,7 +1622,8 @@ test "integer after float has proper type" {...@@ -1622,7 +1622,8 @@ test "integer after float has proper type" {
1622}1622}
16231623
1624test "escaped characters" {1624test "escaped characters" {
1625 var memory: [1024 * 16]u8 = undefined;1625 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
1626 defer arena_allocator.deinit();
1626 const input =1627 const input =
1627 \\{1628 \\{
1628 \\ "backslash": "\\",1629 \\ "backslash": "\\",
...@@ -1638,7 +1639,7 @@ test "escaped characters" {...@@ -1638,7 +1639,7 @@ test "escaped characters" {
1638 \\}1639 \\}
1639 ;1640 ;
16401641
1641 const obj = (try test_parse(&memory, input)).Object;1642 const obj = (try test_parse(&arena_allocator.allocator, input)).Object;
16421643
1643 testing.expectEqualSlices(u8, obj.get("backslash").?.value.String, "\\");1644 testing.expectEqualSlices(u8, obj.get("backslash").?.value.String, "\\");
1644 testing.expectEqualSlices(u8, obj.get("forwardslash").?.value.String, "/");1645 testing.expectEqualSlices(u8, obj.get("forwardslash").?.value.String, "/");
...@@ -1662,13 +1663,13 @@ test "string copy option" {...@@ -1662,13 +1663,13 @@ test "string copy option" {
1662 \\}1663 \\}
1663 ;1664 ;
16641665
1665 var mem_buffer: [1024 * 16]u8 = undefined;1666 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
1666 var buf_alloc = std.heap.FixedBufferAllocator.init(&mem_buffer);1667 defer arena_allocator.deinit();
16671668
1668 const tree_nocopy = try Parser.init(&buf_alloc.allocator, false).parse(input);1669 const tree_nocopy = try Parser.init(&arena_allocator.allocator, false).parse(input);
1669 const obj_nocopy = tree_nocopy.root.Object;1670 const obj_nocopy = tree_nocopy.root.Object;
16701671
1671 const tree_copy = try Parser.init(&buf_alloc.allocator, true).parse(input);1672 const tree_copy = try Parser.init(&arena_allocator.allocator, true).parse(input);
1672 const obj_copy = tree_copy.root.Object;1673 const obj_copy = tree_copy.root.Object;
16731674
1674 for ([_][]const u8{ "noescape", "simple", "unicode", "surrogatepair" }) |field_name| {1675 for ([_][]const u8{ "noescape", "simple", "unicode", "surrogatepair" }) |field_name| {
lib/std/json/write_stream.zig+3-3
...@@ -254,11 +254,11 @@ test "json write stream" {...@@ -254,11 +254,11 @@ test "json write stream" {
254 var slice_stream = std.io.SliceOutStream.init(&out_buf);254 var slice_stream = std.io.SliceOutStream.init(&out_buf);
255 const out = &slice_stream.stream;255 const out = &slice_stream.stream;
256256
257 var mem_buf: [1024 * 10]u8 = undefined;257 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
258 const allocator = &std.heap.FixedBufferAllocator.init(&mem_buf).allocator;258 defer arena_allocator.deinit();
259259
260 var w = std.json.WriteStream(@TypeOf(out).Child, 10).init(out);260 var w = std.json.WriteStream(@TypeOf(out).Child, 10).init(out);
261 try w.emitJson(try getJson(allocator));261 try w.emitJson(try getJson(&arena_allocator.allocator));
262262
263 const result = slice_stream.getWritten();263 const result = slice_stream.getWritten();
264 const expected =264 const expected =
lib/std/math/big/rational.zig+98-53
...@@ -587,14 +587,13 @@ fn gcdLehmer(r: *Int, xa: Int, ya: Int) !void {...@@ -587,14 +587,13 @@ fn gcdLehmer(r: *Int, xa: Int, ya: Int) !void {
587 r.swap(&x);587 r.swap(&x);
588}588}
589589
590var buffer: [64 * 8192]u8 = undefined;
591var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]);
592var al = &fixed.allocator;
593
594test "big.rational gcd non-one small" {590test "big.rational gcd non-one small" {
595 var a = try Int.initSet(al, 17);591 var a = try Int.initSet(testing.allocator, 17);
596 var b = try Int.initSet(al, 97);592 defer a.deinit();
597 var r = try Int.init(al);593 var b = try Int.initSet(testing.allocator, 97);
594 defer b.deinit();
595 var r = try Int.init(testing.allocator);
596 defer r.deinit();
598597
599 try gcd(&r, a, b);598 try gcd(&r, a, b);
600599
...@@ -602,9 +601,12 @@ test "big.rational gcd non-one small" {...@@ -602,9 +601,12 @@ test "big.rational gcd non-one small" {
602}601}
603602
604test "big.rational gcd non-one small" {603test "big.rational gcd non-one small" {
605 var a = try Int.initSet(al, 4864);604 var a = try Int.initSet(testing.allocator, 4864);
606 var b = try Int.initSet(al, 3458);605 defer a.deinit();
607 var r = try Int.init(al);606 var b = try Int.initSet(testing.allocator, 3458);
607 defer b.deinit();
608 var r = try Int.init(testing.allocator);
609 defer r.deinit();
608610
609 try gcd(&r, a, b);611 try gcd(&r, a, b);
610612
...@@ -612,9 +614,12 @@ test "big.rational gcd non-one small" {...@@ -612,9 +614,12 @@ test "big.rational gcd non-one small" {
612}614}
613615
614test "big.rational gcd non-one large" {616test "big.rational gcd non-one large" {
615 var a = try Int.initSet(al, 0xffffffffffffffff);617 var a = try Int.initSet(testing.allocator, 0xffffffffffffffff);
616 var b = try Int.initSet(al, 0xffffffffffffffff7777);618 defer a.deinit();
617 var r = try Int.init(al);619 var b = try Int.initSet(testing.allocator, 0xffffffffffffffff7777);
620 defer b.deinit();
621 var r = try Int.init(testing.allocator);
622 defer r.deinit();
618623
619 try gcd(&r, a, b);624 try gcd(&r, a, b);
620625
...@@ -622,9 +627,12 @@ test "big.rational gcd non-one large" {...@@ -622,9 +627,12 @@ test "big.rational gcd non-one large" {
622}627}
623628
624test "big.rational gcd large multi-limb result" {629test "big.rational gcd large multi-limb result" {
625 var a = try Int.initSet(al, 0x12345678123456781234567812345678123456781234567812345678);630 var a = try Int.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678);
626 var b = try Int.initSet(al, 0x12345671234567123456712345671234567123456712345671234567);631 defer a.deinit();
627 var r = try Int.init(al);632 var b = try Int.initSet(testing.allocator, 0x12345671234567123456712345671234567123456712345671234567);
633 defer b.deinit();
634 var r = try Int.init(testing.allocator);
635 defer r.deinit();
628636
629 try gcd(&r, a, b);637 try gcd(&r, a, b);
630638
...@@ -632,9 +640,12 @@ test "big.rational gcd large multi-limb result" {...@@ -632,9 +640,12 @@ test "big.rational gcd large multi-limb result" {
632}640}
633641
634test "big.rational gcd one large" {642test "big.rational gcd one large" {
635 var a = try Int.initSet(al, 1897056385327307);643 var a = try Int.initSet(testing.allocator, 1897056385327307);
636 var b = try Int.initSet(al, 2251799813685248);644 defer a.deinit();
637 var r = try Int.init(al);645 var b = try Int.initSet(testing.allocator, 2251799813685248);
646 defer b.deinit();
647 var r = try Int.init(testing.allocator);
648 defer r.deinit();
638649
639 try gcd(&r, a, b);650 try gcd(&r, a, b);
640651
...@@ -661,7 +672,8 @@ fn extractLowBits(a: Int, comptime T: type) T {...@@ -661,7 +672,8 @@ fn extractLowBits(a: Int, comptime T: type) T {
661}672}
662673
663test "big.rational extractLowBits" {674test "big.rational extractLowBits" {
664 var a = try Int.initSet(al, 0x11112222333344441234567887654321);675 var a = try Int.initSet(testing.allocator, 0x11112222333344441234567887654321);
676 defer a.deinit();
665677
666 const a1 = extractLowBits(a, u8);678 const a1 = extractLowBits(a, u8);
667 testing.expect(a1 == 0x21);679 testing.expect(a1 == 0x21);
...@@ -680,7 +692,8 @@ test "big.rational extractLowBits" {...@@ -680,7 +692,8 @@ test "big.rational extractLowBits" {
680}692}
681693
682test "big.rational set" {694test "big.rational set" {
683 var a = try Rational.init(al);695 var a = try Rational.init(testing.allocator);
696 defer a.deinit();
684697
685 try a.setInt(5);698 try a.setInt(5);
686 testing.expect((try a.p.to(u32)) == 5);699 testing.expect((try a.p.to(u32)) == 5);
...@@ -708,7 +721,8 @@ test "big.rational set" {...@@ -708,7 +721,8 @@ test "big.rational set" {
708}721}
709722
710test "big.rational setFloat" {723test "big.rational setFloat" {
711 var a = try Rational.init(al);724 var a = try Rational.init(testing.allocator);
725 defer a.deinit();
712726
713 try a.setFloat(f64, 2.5);727 try a.setFloat(f64, 2.5);
714 testing.expect((try a.p.to(i32)) == 5);728 testing.expect((try a.p.to(i32)) == 5);
...@@ -732,7 +746,8 @@ test "big.rational setFloat" {...@@ -732,7 +746,8 @@ test "big.rational setFloat" {
732}746}
733747
734test "big.rational setFloatString" {748test "big.rational setFloatString" {
735 var a = try Rational.init(al);749 var a = try Rational.init(testing.allocator);
750 defer a.deinit();
736751
737 try a.setFloatString("72.14159312071241458852455252781510353");752 try a.setFloatString("72.14159312071241458852455252781510353");
738753
...@@ -742,7 +757,8 @@ test "big.rational setFloatString" {...@@ -742,7 +757,8 @@ test "big.rational setFloatString" {
742}757}
743758
744test "big.rational toFloat" {759test "big.rational toFloat" {
745 var a = try Rational.init(al);760 var a = try Rational.init(testing.allocator);
761 defer a.deinit();
746762
747 // = 3.14159297943115234375763 // = 3.14159297943115234375
748 try a.setRatio(3294199, 1048576);764 try a.setRatio(3294199, 1048576);
...@@ -754,7 +770,8 @@ test "big.rational toFloat" {...@@ -754,7 +770,8 @@ test "big.rational toFloat" {
754}770}
755771
756test "big.rational set/to Float round-trip" {772test "big.rational set/to Float round-trip" {
757 var a = try Rational.init(al);773 var a = try Rational.init(testing.allocator);
774 defer a.deinit();
758 var prng = std.rand.DefaultPrng.init(0x5EED);775 var prng = std.rand.DefaultPrng.init(0x5EED);
759 var i: usize = 0;776 var i: usize = 0;
760 while (i < 512) : (i += 1) {777 while (i < 512) : (i += 1) {
...@@ -765,23 +782,29 @@ test "big.rational set/to Float round-trip" {...@@ -765,23 +782,29 @@ test "big.rational set/to Float round-trip" {
765}782}
766783
767test "big.rational copy" {784test "big.rational copy" {
768 var a = try Rational.init(al);785 var a = try Rational.init(testing.allocator);
786 defer a.deinit();
769787
770 const b = try Int.initSet(al, 5);788 const b = try Int.initSet(testing.allocator, 5);
789 defer b.deinit();
771790
772 try a.copyInt(b);791 try a.copyInt(b);
773 testing.expect((try a.p.to(u32)) == 5);792 testing.expect((try a.p.to(u32)) == 5);
774 testing.expect((try a.q.to(u32)) == 1);793 testing.expect((try a.q.to(u32)) == 1);
775794
776 const c = try Int.initSet(al, 7);795 const c = try Int.initSet(testing.allocator, 7);
777 const d = try Int.initSet(al, 3);796 defer c.deinit();
797 const d = try Int.initSet(testing.allocator, 3);
798 defer d.deinit();
778799
779 try a.copyRatio(c, d);800 try a.copyRatio(c, d);
780 testing.expect((try a.p.to(u32)) == 7);801 testing.expect((try a.p.to(u32)) == 7);
781 testing.expect((try a.q.to(u32)) == 3);802 testing.expect((try a.q.to(u32)) == 3);
782803
783 const e = try Int.initSet(al, 9);804 const e = try Int.initSet(testing.allocator, 9);
784 const f = try Int.initSet(al, 3);805 defer e.deinit();
806 const f = try Int.initSet(testing.allocator, 3);
807 defer f.deinit();
785808
786 try a.copyRatio(e, f);809 try a.copyRatio(e, f);
787 testing.expect((try a.p.to(u32)) == 3);810 testing.expect((try a.p.to(u32)) == 3);
...@@ -789,7 +812,8 @@ test "big.rational copy" {...@@ -789,7 +812,8 @@ test "big.rational copy" {
789}812}
790813
791test "big.rational negate" {814test "big.rational negate" {
792 var a = try Rational.init(al);815 var a = try Rational.init(testing.allocator);
816 defer a.deinit();
793817
794 try a.setInt(-50);818 try a.setInt(-50);
795 testing.expect((try a.p.to(i32)) == -50);819 testing.expect((try a.p.to(i32)) == -50);
...@@ -805,7 +829,8 @@ test "big.rational negate" {...@@ -805,7 +829,8 @@ test "big.rational negate" {
805}829}
806830
807test "big.rational abs" {831test "big.rational abs" {
808 var a = try Rational.init(al);832 var a = try Rational.init(testing.allocator);
833 defer a.deinit();
809834
810 try a.setInt(-50);835 try a.setInt(-50);
811 testing.expect((try a.p.to(i32)) == -50);836 testing.expect((try a.p.to(i32)) == -50);
...@@ -821,8 +846,10 @@ test "big.rational abs" {...@@ -821,8 +846,10 @@ test "big.rational abs" {
821}846}
822847
823test "big.rational swap" {848test "big.rational swap" {
824 var a = try Rational.init(al);849 var a = try Rational.init(testing.allocator);
825 var b = try Rational.init(al);850 defer a.deinit();
851 var b = try Rational.init(testing.allocator);
852 defer b.deinit();
826853
827 try a.setRatio(50, 23);854 try a.setRatio(50, 23);
828 try b.setRatio(17, 3);855 try b.setRatio(17, 3);
...@@ -843,8 +870,10 @@ test "big.rational swap" {...@@ -843,8 +870,10 @@ test "big.rational swap" {
843}870}
844871
845test "big.rational cmp" {872test "big.rational cmp" {
846 var a = try Rational.init(al);873 var a = try Rational.init(testing.allocator);
847 var b = try Rational.init(al);874 defer a.deinit();
875 var b = try Rational.init(testing.allocator);
876 defer b.deinit();
848877
849 try a.setRatio(500, 231);878 try a.setRatio(500, 231);
850 try b.setRatio(18903, 8584);879 try b.setRatio(18903, 8584);
...@@ -856,8 +885,10 @@ test "big.rational cmp" {...@@ -856,8 +885,10 @@ test "big.rational cmp" {
856}885}
857886
858test "big.rational add single-limb" {887test "big.rational add single-limb" {
859 var a = try Rational.init(al);888 var a = try Rational.init(testing.allocator);
860 var b = try Rational.init(al);889 defer a.deinit();
890 var b = try Rational.init(testing.allocator);
891 defer b.deinit();
861892
862 try a.setRatio(500, 231);893 try a.setRatio(500, 231);
863 try b.setRatio(18903, 8584);894 try b.setRatio(18903, 8584);
...@@ -869,9 +900,12 @@ test "big.rational add single-limb" {...@@ -869,9 +900,12 @@ test "big.rational add single-limb" {
869}900}
870901
871test "big.rational add" {902test "big.rational add" {
872 var a = try Rational.init(al);903 var a = try Rational.init(testing.allocator);
873 var b = try Rational.init(al);904 defer a.deinit();
874 var r = try Rational.init(al);905 var b = try Rational.init(testing.allocator);
906 defer b.deinit();
907 var r = try Rational.init(testing.allocator);
908 defer r.deinit();
875909
876 try a.setRatio(78923, 23341);910 try a.setRatio(78923, 23341);
877 try b.setRatio(123097, 12441414);911 try b.setRatio(123097, 12441414);
...@@ -882,9 +916,12 @@ test "big.rational add" {...@@ -882,9 +916,12 @@ test "big.rational add" {
882}916}
883917
884test "big.rational sub" {918test "big.rational sub" {
885 var a = try Rational.init(al);919 var a = try Rational.init(testing.allocator);
886 var b = try Rational.init(al);920 defer a.deinit();
887 var r = try Rational.init(al);921 var b = try Rational.init(testing.allocator);
922 defer b.deinit();
923 var r = try Rational.init(testing.allocator);
924 defer r.deinit();
888925
889 try a.setRatio(78923, 23341);926 try a.setRatio(78923, 23341);
890 try b.setRatio(123097, 12441414);927 try b.setRatio(123097, 12441414);
...@@ -895,9 +932,12 @@ test "big.rational sub" {...@@ -895,9 +932,12 @@ test "big.rational sub" {
895}932}
896933
897test "big.rational mul" {934test "big.rational mul" {
898 var a = try Rational.init(al);935 var a = try Rational.init(testing.allocator);
899 var b = try Rational.init(al);936 defer a.deinit();
900 var r = try Rational.init(al);937 var b = try Rational.init(testing.allocator);
938 defer b.deinit();
939 var r = try Rational.init(testing.allocator);
940 defer r.deinit();
901941
902 try a.setRatio(78923, 23341);942 try a.setRatio(78923, 23341);
903 try b.setRatio(123097, 12441414);943 try b.setRatio(123097, 12441414);
...@@ -908,9 +948,12 @@ test "big.rational mul" {...@@ -908,9 +948,12 @@ test "big.rational mul" {
908}948}
909949
910test "big.rational div" {950test "big.rational div" {
911 var a = try Rational.init(al);951 var a = try Rational.init(testing.allocator);
912 var b = try Rational.init(al);952 defer a.deinit();
913 var r = try Rational.init(al);953 var b = try Rational.init(testing.allocator);
954 defer b.deinit();
955 var r = try Rational.init(testing.allocator);
956 defer r.deinit();
914957
915 try a.setRatio(78923, 23341);958 try a.setRatio(78923, 23341);
916 try b.setRatio(123097, 12441414);959 try b.setRatio(123097, 12441414);
...@@ -921,8 +964,10 @@ test "big.rational div" {...@@ -921,8 +964,10 @@ test "big.rational div" {
921}964}
922965
923test "big.rational div" {966test "big.rational div" {
924 var a = try Rational.init(al);967 var a = try Rational.init(testing.allocator);
925 var r = try Rational.init(al);968 defer a.deinit();
969 var r = try Rational.init(testing.allocator);
970 defer r.deinit();
926971
927 try a.setRatio(78923, 23341);972 try a.setRatio(78923, 23341);
928 a.invert();973 a.invert();
lib/std/mem.zig+30-14
...@@ -1011,11 +1011,21 @@ pub fn join(allocator: *Allocator, separator: []const u8, slices: []const []cons...@@ -1011,11 +1011,21 @@ pub fn join(allocator: *Allocator, separator: []const u8, slices: []const []cons
1011}1011}
10121012
1013test "mem.join" {1013test "mem.join" {
1014 var buf: [1024]u8 = undefined;1014 {
1015 const a = &std.heap.FixedBufferAllocator.init(&buf).allocator;1015 const str = try join(testing.allocator, ",", &[_][]const u8{ "a", "b", "c" });
1016 testing.expect(eql(u8, try join(a, ",", &[_][]const u8{ "a", "b", "c" }), "a,b,c"));1016 defer testing.allocator.free(str);
1017 testing.expect(eql(u8, try join(a, ",", &[_][]const u8{"a"}), "a"));1017 testing.expect(eql(u8, str, "a,b,c"));
1018 testing.expect(eql(u8, try join(a, ",", &[_][]const u8{ "a", "", "b", "", "c" }), "a,,b,,c"));1018 }
1019 {
1020 const str = try join(testing.allocator, ",", &[_][]const u8{"a"});
1021 defer testing.allocator.free(str);
1022 testing.expect(eql(u8, str, "a"));
1023 }
1024 {
1025 const str = try join(testing.allocator, ",", &[_][]const u8{ "a", "", "b", "", "c" });
1026 defer testing.allocator.free(str);
1027 testing.expect(eql(u8, str, "a,,b,,c"));
1028 }
1019}1029}
10201030
1021/// Copies each T from slices into a new slice that exactly holds all the elements.1031/// Copies each T from slices into a new slice that exactly holds all the elements.
...@@ -1044,15 +1054,21 @@ pub fn concat(allocator: *Allocator, comptime T: type, slices: []const []const T...@@ -1044,15 +1054,21 @@ pub fn concat(allocator: *Allocator, comptime T: type, slices: []const []const T
1044}1054}
10451055
1046test "concat" {1056test "concat" {
1047 var buf: [1024]u8 = undefined;1057 {
1048 const a = &std.heap.FixedBufferAllocator.init(&buf).allocator;1058 const str = try concat(testing.allocator, u8, &[_][]const u8{ "abc", "def", "ghi" });
1049 testing.expect(eql(u8, try concat(a, u8, &[_][]const u8{ "abc", "def", "ghi" }), "abcdefghi"));1059 defer testing.allocator.free(str);
1050 testing.expect(eql(u32, try concat(a, u32, &[_][]const u32{1060 testing.expect(eql(u8, str, "abcdefghi"));
1051 &[_]u32{ 0, 1 },1061 }
1052 &[_]u32{ 2, 3, 4 },1062 {
1053 &[_]u32{},1063 const str = try concat(testing.allocator, u32, &[_][]const u32{
1054 &[_]u32{5},1064 &[_]u32{ 0, 1 },
1055 }), &[_]u32{ 0, 1, 2, 3, 4, 5 }));1065 &[_]u32{ 2, 3, 4 },
1066 &[_]u32{},
1067 &[_]u32{5},
1068 });
1069 defer testing.allocator.free(str);
1070 testing.expect(eql(u32, str, &[_]u32{ 0, 1, 2, 3, 4, 5 }));
1071 }
1056}1072}
10571073
1058test "testStringEquality" {1074test "testStringEquality" {
lib/std/net/test.zig+1-3
...@@ -67,10 +67,8 @@ test "resolve DNS" {...@@ -67,10 +67,8 @@ test "resolve DNS" {
67 // DNS resolution not implemented on Windows yet.67 // DNS resolution not implemented on Windows yet.
68 return error.SkipZigTest;68 return error.SkipZigTest;
69 }69 }
70 var buf: [1000 * 10]u8 = undefined;
71 const a = &std.heap.FixedBufferAllocator.init(&buf).allocator;
7270
73 const address_list = net.getAddressList(a, "example.com", 80) catch |err| switch (err) {71 const address_list = net.getAddressList(testing.allocator, "example.com", 80) catch |err| switch (err) {
74 // The tests are required to work even when there is no Internet connection,72 // The tests are required to work even when there is no Internet connection,
75 // so some of these errors we must accept and skip the test.73 // so some of these errors we must accept and skip the test.
76 error.UnknownHostName => return error.SkipZigTest,74 error.UnknownHostName => return error.SkipZigTest,