File: tests.pl

package info (click to toggle)
swi-prolog 9.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 82,408 kB
  • sloc: ansic: 387,503; perl: 359,326; cpp: 6,613; lisp: 6,247; java: 5,540; sh: 3,147; javascript: 2,668; python: 1,900; ruby: 1,594; yacc: 845; makefile: 428; xml: 317; sed: 12; sql: 6
file content (27 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% Miscellaneous tests.

% TODO: use library(plunit)

:- module(bootstrap_tests,
          [
           test_segment_messages/1
          ]).

:- use_module(library(protobufs)).

%! test_segment_messages is det.
% Tests round-trip of segment_protobuf_segment_message/2,
% using the protobuf wire form of descriptor.proto.
% You may wish to compare the contents of =Segments= with
% the output from protoc --decode_raw
test_segment_messages(Path) :- % Path = 'descriptor.proto.wire'
    read_file_to_codes(Path, WireStream, [encoding(octet),type(binary)]),
    protobufs:protobuf_segment_message(Segments, WireStream),
    % Check that it reverses:
    protobufs:protobuf_segment_message(Segments, WireStream2),
    assertion(WireStream == WireStream2),
    Segments = [message(1, MessageSegments)],
    length(MessageSegments, MessageSegmentsLen),
    format('test_segment_messages succeeded with ~d segment(s) in the message.~n', [MessageSegmentsLen]),
    % Don't print it out in all its glory because it's rather long.
    true. % print_term(Segments, [indent_arguments(4), tab_width(0), right_margin(88)]), nl.