55 lines
2.3 KiB
Plaintext
55 lines
2.3 KiB
Plaintext
# Tests of a module's lines: the blocks of each file's lines with their
|
|
# columns, the subsections holding them, and the annotations of inline sites.
|
|
import std::io;
|
|
import binary::pdb;
|
|
import std::testing;
|
|
|
|
|
|
@test def lines_are_written_in_a_block_for_each_file(t: &mut tester): void {
|
|
var lines := pdb::function_lines::new(1, 0x10, 0x20);
|
|
lines.line(0, 0, 3, 5);
|
|
lines.line(0, 8, 4, 1);
|
|
lines.line(8, 12, 9, 2);
|
|
lines.finish();
|
|
var expected := string::new(nothing {});
|
|
expected.append("100000000100010020000000"); # Where the code is, with columns,
|
|
expected.append("000000000200000024000000000000000300008008000000040000800500000001000000"); # the first file's,
|
|
expected.append("0800000001000000180000000c0000000900008002000000"); # and the second's.
|
|
t.expects(hex_of(lines.bytes.view()).view() == expected.view(), hex_of(lines.bytes.view()).view());
|
|
|
|
var section := byte_writer::new();
|
|
pdb::subsection(&mut section, pdb::debug_s_lines, "abc");
|
|
t.expects(hex_of(section.view()).view() == "f20000000300000061626300");
|
|
}
|
|
|
|
@test def files_are_named_by_where_their_entries_are(t: &mut tester): void {
|
|
var sums := pdb::file_checksums::new();
|
|
t.expects(sums.file(1) == 0 && sums.file(9) == 8);
|
|
t.expects(hex_of(sums.bytes.view()).view() == "01000000000000000900000000000000");
|
|
var inlinees := pdb::inlinee_lines::new();
|
|
inlinees.add(0x1000, 8, 42);
|
|
t.expects(inlinees.count == 1 && hex_of(inlinees.bytes.view()).view() == "0000000000100000080000002a000000");
|
|
}
|
|
|
|
@test def annotations_say_each_part_of_a_site_and_its_line(t: &mut tester): void {
|
|
var notes := pdb::annotations::new(0, 10);
|
|
# The first part, of the line the function begins at, says it is.
|
|
notes.at_line(0x20, 0, 10);
|
|
t.expects(hex_of(notes.bytes.view()).view() == "06000320");
|
|
# A near part a near line on is one annotation.
|
|
notes.at_line(0x24, 0, 12);
|
|
# A part of the same line goes on.
|
|
notes.at_line(0x26, 0, 12);
|
|
# Code not the site's ends the part, then a part of another file follows.
|
|
notes.away(0x30);
|
|
notes.at_line(0x40, 8, 11);
|
|
notes.finish(0x48);
|
|
t.expects(hex_of(notes.bytes.view()).view() == "060003200b44040c0508060303100408");
|
|
|
|
# Lengths and offsets past seven bits take two bytes.
|
|
var far := pdb::annotations::new(0, 1);
|
|
far.at_line(0x1234, 0, 1);
|
|
far.finish(0x1240);
|
|
t.expects(hex_of(far.bytes.view()).view() == "0600039234040c");
|
|
}
|