-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
MIT: | ||
= https://spdx.org/licenses/MIT | ||
- This | ||
- git https://github.com/nektro/zig-expect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const std = @import("std"); | ||
const bencode = @import("bencode"); | ||
const expect = @import("expect").expect; | ||
|
||
test { | ||
const alloc = std.testing.allocator; | ||
const file = @embedFile("./archlinux-2021.04.01-x86_64.iso.torrent"); | ||
|
||
var fbs = std.io.fixedBufferStream(file); | ||
const r = fbs.reader(); | ||
const ben = try bencode.parse(r, alloc); | ||
defer ben.deinit(alloc); | ||
|
||
try expect(ben.getS("comment")).toEqualString("Arch Linux 2021.04.01 (www.archlinux.org)"); | ||
try expect(ben.getS("created by")).toEqualString("mktorrent 1.1"); | ||
try expect(ben.getU("creation date")).toEqual(1617297570); | ||
try expect(ben.getD("info")).not().toBeNull(); | ||
try expect(ben.getD("info").?.getU("length")).toEqual(786771968); | ||
try expect(ben.getD("info").?.getS("name")).toEqualString("archlinux-2021.04.01-x86_64.iso"); | ||
try expect(ben.getD("info").?.getU("piece length")).toEqual(524288); | ||
try expect(ben.getD("info").?.getS("pieces").?.len).toEqual(30020); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters