78 lines
2.0 KiB
Lua
78 lines
2.0 KiB
Lua
-- -%- indent-width:2 -%- --
|
|
|
|
require("munit")
|
|
require("gtk")
|
|
|
|
local function test1()
|
|
f1 = gtk.g_file_new_for_path('/tmp/foo')
|
|
f2 = f1.dup()
|
|
tassert(f1 ~= f2)
|
|
tassert(f1.get_basename() == 'foo')
|
|
tassert(f1.equal(f2))
|
|
tassert(f1:equal(f2))
|
|
d = f1.get_parent()
|
|
tassert(d.get_path() == '/tmp')
|
|
c = d.get_child('foo')
|
|
tassert(f1.equal(c))
|
|
c = d.get_child_for_display_name('foo')
|
|
tassert(f1.equal(c))
|
|
tassert(f1.get_parse_name() == '/tmp/foo')
|
|
tassert(d.get_relative_path(c) == 'foo')
|
|
tassert(c.get_uri() == 'file:///tmp/foo')
|
|
tassert(c.get_uri_scheme() == 'file')
|
|
c.hash()
|
|
tassert(c.has_parent())
|
|
tassert(c.has_parent(d))
|
|
tassert(d.has_parent())
|
|
root = d.get_parent()
|
|
tassert(d.has_parent(root))
|
|
tassert(not root.has_parent())
|
|
tassert(d.has_prefix(root))
|
|
tassert(c.has_prefix(root))
|
|
tassert(c.has_prefix(d))
|
|
tassert(not c:has_prefix(c))
|
|
tassert(not d.has_prefix(c))
|
|
tassert(d.has_uri_scheme('file'))
|
|
tassert(d.is_native())
|
|
tassert(d.resolve_relative_path('foo').equal(f1))
|
|
tassert(d.resolve_relative_path('../tmp').equal(d))
|
|
end
|
|
|
|
local function test2()
|
|
f1 = gtk.g_file_new_for_uri('http://example.com/foo/bar.txt')
|
|
f2 = f1.dup()
|
|
tassert(f1 ~= f2)
|
|
tassert(f1.get_basename() == 'bar.txt')
|
|
tassert(f1.equal(f2))
|
|
tassert(f1:equal(f2))
|
|
d = f1.get_parent()
|
|
tassert(d.get_path() == nil)
|
|
tassert(d.get_uri() == 'http://example.com/foo')
|
|
c = d.get_child('bar.txt')
|
|
tassert(f1.equal(c))
|
|
c = d.get_child_for_display_name('bar.txt')
|
|
tassert(f1.equal(c))
|
|
tassert(f1.get_parse_name() == 'http://example.com/foo/bar.txt')
|
|
tassert(c.get_uri_scheme() == 'http')
|
|
c.hash()
|
|
tassert(c.has_parent())
|
|
tassert(c.has_parent(d))
|
|
tassert(d.has_parent())
|
|
root = d.get_parent()
|
|
tassert(d.has_parent(root))
|
|
tassert(not root.has_parent())
|
|
tassert(d.has_uri_scheme('http'))
|
|
tassert(not d.is_native())
|
|
tassert(d.resolve_relative_path('bar.txt').equal(f1))
|
|
end
|
|
|
|
local function test3()
|
|
f = gtk.g_file_parse_name('/tmp/foo')
|
|
f2 = gtk.g_file_new_for_path('/tmp/foo')
|
|
tassert(f.equal(f2))
|
|
end
|
|
|
|
test1()
|
|
test2()
|
|
test3()
|