head	1.1;
branch	1.1.1;
access;
symbols
	tonic_4:1.1.1.1
	tonic_3:1.1.1.1
	tonic_2:1.1.1.1
	demo:1.1.1.1.0.8
	design_report:1.1.1.1
	dec2:1.1.1.1
	oral_presentation_freeze:1.1.1.1.0.6
	DAVEG_CDP:1.1.1.1.0.4
	template_integ:1.1.1.1.0.2
	v1_1:1.1.1.1
	nov19:1.1.1.1
	course_staff:1.1.1;
locks; strict;
comment	@ * @;


1.1
date	95.11.19.05.50.04;	author hartmans;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	95.11.19.05.50.05;	author hartmans;	state Exp;
branches;
next	;


desc
@@



1.1
log
@Initial revision
@
text
@#include "ps5/url_ops.h"

// black box tests for "url_ops.h"

static int test = 0;

void result(string x, string y) {
    test++;
    if (x != y) {
	cout << "Test " << test++ << ": expected <"
	     << y << ">, got <"<<x << ">\n";
    }
}

main(int argc, char *argv[]) {
    result(extract_pathname("/?foo"), "");
    result(extract_pathname("?foo"), "");
    result(extract_pathname("///?foo"), "");
    result(extract_pathname("/aa/b/?foo"), "aa/b/");
    result(extract_pathname("/aa/b/?/foo"), "aa/b/");
    result(extract_pathname("/aa/b/c?/foo"), "aa/b/c");
    result(extract_pathname("/aa?/foo"), "aa");
    result(extract_pathname("aa?/foo"), "aa");
    result(extract_pathname("?"), "");
    result(extract_pathname("///"), "");
    result(extract_pathname(""), "");
    result(extract_pathname("///?"), "");
    result(extract_query("/a/b/c?foo"), "foo");
    result(extract_query("/a/b/c?"), "");
    result(extract_query("/a/b/c"), "");
    result(extract_query("?foo/bar"), "foo/bar");
    result(extract_query("?"), "");
    result(extract_query(""), "");
    result(first_component("/a/b/c"), "a");
    result(first_component("/aa/b/c"), "aa");
    result(first_component("a/b/c"), "a");
    result(first_component("aa/b/c"), "aa");
    result(first_component("///a/b/c"), "a");
    result(first_component("a"), "a");
    result(first_component("/a"), "a");
    result(first_component("/abc"), "abc");
    result(first_component("/a/"), "a");
    result(first_component("/abc/"), "abc");
    result(first_component("/"), "");
    result(first_component("////"), "");
    result(first_component(""), "");
    result(last_component("/aa/b/c"), "c");
    result(last_component("/a/b/c"), "c");
    result(last_component("a/b/c/"), "c");
    result(last_component("aa/b/c//"), "c");
    result(last_component("///"), "");
    result(last_component("/"), "");
    result(last_component(""), "");
    result(last_component("a"), "a");
    result(last_component("a/"), "a");
    result(last_component("/a"), "a");
    result(rest_components("/a/b/c"), "b/c");
    result(rest_components("//a/b/c//"), "b/c//");
    result(rest_components("a/b"), "b");
    result(rest_components("a///b/"), "b/");
    result(extension("foo.txt"), "txt");
    result(extension("foo"), "");
    result(extension("a.foo/foo"), "");
    result(extension("a.foo/foo.bar"), "bar");
    result(extension("foo."), "");
    result(extension(".txt"), "txt");
    result(extension("foo.txt///"), "txt");
    result(extension("foo.txt/"), "txt");
    result(extension("txt/"), "");
    result(extension(""), "");
    result(extension("/"), "");
    result(extension("///"), "");
}
@


1.1.1.1
log
@Bring web_server code into our tree
@
text
@@
