static void test_path_parsing() { FmPath* path; TEST_PARSING(fm_path_new_for_path, "/test/path", "/", "test", "path"); TEST_PARSING(fm_path_new_for_path, "/test/path/", "/", "test", "path"); TEST_PARSING(fm_path_new_for_path, "/test/path//", "/", "test", "path"); TEST_PARSING(fm_path_new_for_path, "/test//path//", "/", "test", "path"); TEST_PARSING(fm_path_new_for_path, "/test///path//", "/", "test", "path"); TEST_PARSING(fm_path_new_for_path, "//test/path", "/", "test", "path"); TEST_PARSING(fm_path_new_for_path, "//", "/"); TEST_PARSING(fm_path_new_for_path, "////", "/"); TEST_PARSING(fm_path_new_for_path, "/", "/"); // canonicalize TEST_PARSING(fm_path_new_for_path, "/test/./path", "/", "test", "path"); TEST_PARSING(fm_path_new_for_path, "/test/../path", "/", "path"); TEST_PARSING(fm_path_new_for_path, "/../path", "/", "path"); TEST_PARSING(fm_path_new_for_path, "/./path", "/", "path"); TEST_PARSING(fm_path_new_for_path, "invalid_path", "/"); TEST_PARSING(fm_path_new_for_path, "", "/"); TEST_PARSING(fm_path_new_for_path, NULL, "/"); }
static void test_uri_parsing() { FmPath* path; // test URIs TEST_PARSING(fm_path_new_for_uri, "file:///test/path/", "/", "test", "path"); TEST_PARSING(fm_path_new_for_uri, "file:/test/path", "/", "test", "path"); TEST_PARSING(fm_path_new_for_uri, "file://test/path", "/", "test", "path"); TEST_PARSING(fm_path_new_for_uri, "http://test/path/", "http://test/", "path"); TEST_PARSING(fm_path_new_for_uri, "http://test", "http://test/"); TEST_PARSING(fm_path_new_for_uri, "http:/test", "http://test/"); TEST_PARSING(fm_path_new_for_uri, "http://////test", "http://test/"); TEST_PARSING(fm_path_new_for_uri, "http://wiki.lxde.org/zh/%E9%A6%96%E9%A0%81", "http://wiki.lxde.org/", "zh", "首頁"); TEST_PARSING(fm_path_new_for_uri, "mailto:test", "mailto:test"); TEST_PARSING(fm_path_new_for_uri, "http://test/path/to/file", "http://test/", "path", "to", "file"); // FIXME: is this ok? TEST_PARSING(fm_path_new_for_uri, "http://test/path/to/file?test_arg=xx", "http://test/", "path", "to", "file?test_arg=xx"); // test user name, password, and port TEST_PARSING(fm_path_new_for_uri, "ftp://user@host", "ftp://user@host/"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host", "ftp://*****:*****@host/"); TEST_PARSING(fm_path_new_for_uri, "ftp://user@host:21", "ftp://user@host:21/"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21", "ftp://*****:*****@host:21/"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/path", "ftp://*****:*****@host:21/", "path"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/path/", "ftp://*****:*****@host:21/", "path"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/path//", "ftp://*****:*****@host:21/", "path"); #if 0 TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/../", "ftp://*****:*****@host:21/", "path"); #endif // test special locations TEST_PARSING(fm_path_new_for_uri, "computer:", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer:/", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer:///", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer://///", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer://device", "computer:///", "device"); TEST_PARSING(fm_path_new_for_uri, "computer:///device", "computer:///", "device"); TEST_PARSING(fm_path_new_for_uri, "trash:", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:/", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash://", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:///", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:////", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:/file/", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash://file", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash:///file/", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash:////file/", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash:///file/../test", "trash:///", "test"); /* TEST_PARSING(fm_path_new_for_uri, "menu:"); TEST_PARSING(fm_path_new_for_uri, "menu:/"); TEST_PARSING(fm_path_new_for_uri, "menu://"); TEST_PARSING(fm_path_new_for_uri, "menu:///"); */ TEST_PARSING(fm_path_new_for_uri, "menu://applications/", "menu://applications/"); TEST_PARSING(fm_path_new_for_uri, "menu://applications/xxxx", "menu://applications/", "xxxx"); TEST_PARSING(fm_path_new_for_uri, "menu://applications/xxxx/", "menu://applications/", "xxxx"); TEST_PARSING(fm_path_new_for_uri, "menu://settings/xxxx/", "menu://settings/", "xxxx"); TEST_PARSING(fm_path_new_for_uri, "menu://settings", "menu://settings/"); /* This is not yet implemented TEST_PARSING(fm_path_new_for_uri, "applications://xxx", "menu://applications/", "xxx"); */ // test invalid URIs, should fallback to root. TEST_PARSING(fm_path_new_for_uri, "invalid_uri", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri:", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri:/", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri:/invalid", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri://///invalid", "/"); TEST_PARSING(fm_path_new_for_uri, "", "/"); TEST_PARSING(fm_path_new_for_uri, NULL, "/"); }
static void test_uri_parsing() { // test URIs TEST_PARSING(fm_path_new_for_uri, "file:///test/path/", "/", "test", "path"); TEST_PARSING(fm_path_new_for_uri, "file:/test/path", "/", "test", "path"); /* The 'test' in this format is a host part of URI */ #if 0 TEST_PARSING(fm_path_new_for_uri, "file://test/path", "/", "path"); #endif /* it is changed since 1.2.0 and file://test/ is handled literally */ TEST_PARSING(fm_path_new_for_uri, "file://test/path", "file://test/", "path"); TEST_PARSING(fm_path_new_for_uri, "http://test/path/", "http://test/", "path"); TEST_PARSING(fm_path_new_for_uri, "http://test", "http://test/"); TEST_PARSING(fm_path_new_for_uri, "http:/test", #if 0 "http://test/"); #endif "http:///", "test"); #if 0 TEST_PARSING(fm_path_new_for_uri, "http://////test", "http://test/"); #endif TEST_PARSING(fm_path_new_for_uri, "http://wiki.lxde.org/zh/%E9%A6%96%E9%A0%81", #if 0 /* It should not do any break in URI since 1.0.1 */ "http://wiki.lxde.org/", "zh", "首頁"); #endif "http://wiki.lxde.org/", "zh", "%E9%A6%96%E9%A0%81"); TEST_PARSING(fm_path_new_for_uri, "mailto:test", "mailto:test"); TEST_PARSING(fm_path_new_for_uri, "http://test/path/to/file", "http://test/", "path", "to", "file"); // FIXME: is this ok? TEST_PARSING(fm_path_new_for_uri, "http://test/path/to/file?test_arg=xx", "http://test/", "path/to/file?test_arg=xx"); // test user name, password, and port TEST_PARSING(fm_path_new_for_uri, "ftp://user@host", "ftp://user@host/"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host", "ftp://*****:*****@host/"); TEST_PARSING(fm_path_new_for_uri, "ftp://user@host:21", "ftp://user@host:21/"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21", "ftp://*****:*****@host:21/"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/path", "ftp://*****:*****@host:21/", "path"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/path/", "ftp://*****:*****@host:21/", "path"); TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/path//", "ftp://*****:*****@host:21/", "path"); #if 0 TEST_PARSING(fm_path_new_for_uri, "ftp://*****:*****@host:21/../", "ftp://*****:*****@host:21/", "path"); #endif // test special locations TEST_PARSING(fm_path_new_for_uri, "computer:", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer:/", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer:///", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer://///", "computer:///"); TEST_PARSING(fm_path_new_for_uri, "computer://device", "computer:///", "device"); TEST_PARSING(fm_path_new_for_uri, "computer:///device", "computer:///", "device"); TEST_PARSING(fm_path_new_for_uri, "trash:", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:/", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash://", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:///", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:////", "trash:///"); TEST_PARSING(fm_path_new_for_uri, "trash:/file/", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash://file", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash:///file/", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash:////file/", "trash:///", "file"); TEST_PARSING(fm_path_new_for_uri, "trash:///file/../test", "trash:///", "test"); /* TEST_PARSING(fm_path_new_for_uri, "menu:"); TEST_PARSING(fm_path_new_for_uri, "menu:/"); TEST_PARSING(fm_path_new_for_uri, "menu://"); TEST_PARSING(fm_path_new_for_uri, "menu:///"); */ TEST_PARSING(fm_path_new_for_uri, "menu://applications/", "menu://applications/"); TEST_PARSING(fm_path_new_for_uri, "menu://applications/xxxx", "menu://applications/", "xxxx"); TEST_PARSING(fm_path_new_for_uri, "menu://applications/xxxx/", "menu://applications/", "xxxx"); TEST_PARSING(fm_path_new_for_uri, "menu://settings/xxxx/", "menu://settings/", "xxxx"); TEST_PARSING(fm_path_new_for_uri, "menu://settings", "menu://settings/"); /* This is not yet implemented TEST_PARSING(fm_path_new_for_uri, "applications://xxx", "menu://applications/", "xxx"); */ // test invalid URIs, should fallback to root. TEST_PARSING(fm_path_new_for_uri, "invalid_uri", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri:", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri:/", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri:/invalid", "/"); TEST_PARSING(fm_path_new_for_uri, "invalid_uri://///invalid", "/"); TEST_PARSING(fm_path_new_for_uri, "", "/"); TEST_PARSING(fm_path_new_for_uri, NULL, "/"); }