/*
 * valac --debug --verbose --save-temps --pkg augeas --vapidir . augeas-api-test-glib.vala
 */

using GLib.Test;
using LibAugeas;

string root;
string loadpath;

void test()
{
	int r;
	string value;
	string[] values;
	Augeas aug;

	aug = new Augeas (root, loadpath, InitFlags.NO_STDINC | InitFlags.NO_LOAD);

	r = aug.match ("/augeas/version/save/*", out values);
	assert (r > 1);
	assert (aug.error() == ErrorCode.NOERROR);
	foreach (string value in values) debug ("vals: %s", value);

	r = aug.get ("/augeas/version/save/*[1]", out value);
	assert (r == 1);
	assert (value != null);
	assert (aug.error() == ErrorCode.NOERROR);
	debug ("val: %s", value);

	r = aug.get ("/augeas/version/save/*[ last() + 1 ]", out value);
	assert (r == 0);
	assert (value == null);
	assert (aug.error() == ErrorCode.NOERROR);
	debug ("val: %s", value);

	r = aug.get ("/augeas/version/save/*", out value);
	assert (r == -1);
	assert (value == null);
	assert (aug.error() == ErrorCode.EMMATCH);

}

int main(string[] args)
{
	root = args[1] + "/tests/root";
	loadpath = args[1] + "/tests/lenses";

	init (ref args);

	add_func ("/augeas/api-test", test);

	return run ();
}

