File: test-prefix-stream.vala

package info (click to toggle)
rpl 2.0.4-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 6,700 kB
  • sloc: ansic: 47,076; sh: 8,700; makefile: 79
file content (48 lines) | stat: -rw-r--r-- 1,692 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/env -S vala --pkg gio-2.0 prefix-stream.vala testcase.vala
// Tests for PrefixInputStream.
//
// © 2025 Alistair Turnbull <apt1002@mupsych.org>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <https://www.gnu.org/licenses/>.

class PrefixStreamTests : GeeTestCase {

	public PrefixStreamTests() {
		base ("PrefixStreamTests");
		add_test ("basic_test", basic_test);
	}

	void basic_test () {
		InputStream input = new MemoryInputStream.from_data (
			"a single man in possession of a good fortune must be in want of a wife.".data
		);
		PrefixInputStream prefix_input = new PrefixInputStream (
			"It is a truth universally acknowledged, that ".data,
			(owned) input
		);
		var output = new uint8[80];
		size_t num_bytes;
		try {
			prefix_input.read_all (output, out num_bytes);
		} catch (IOError e) {}
		assert_true ((string) output == "It is a truth universally acknowledged, that a single man in possession of a goo");
	}
}

public static int main (string[] args) {
	Test.init (ref args);
	Test.set_nonfatal_assertions ();
	TestSuite.get_root ().add_suite (new PrefixStreamTests ().get_suite ());
	return Test.run ();
}