]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/c_glib/test/test-file-info.rb
e6a3a0d62a5b9ccfe662cf6d00f44cddbae33fbd
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
18 class TestFileInfo
< Test
::Unit::TestCase
20 @file_info = Arrow
::FileInfo.new
23 sub_test_case("#type") do
25 assert_equal(Arrow
::FileType::UNKNOWN,
31 @file_info.type
= :dir
32 assert_equal(Arrow
::FileType::DIR,
36 sub_test_case("#path") do
38 assert_equal("", @file_info.path
)
43 @file_info.path
= "/a/b/c.d"
44 assert_equal("/a/b/c.d",
48 sub_test_case("#base_name") do
50 assert_equal("", @file_info.base_name
)
53 test("with directory") do
54 @file_info.path
= "/a/b/c.d"
55 assert_equal("c.d", @file_info.base_name
)
59 sub_test_case("#dir_name") do
61 assert_equal("", @file_info.dir_name
)
64 test("with directory") do
65 @file_info.path
= "/a/b/c.d"
66 assert_equal("/a/b", @file_info.dir_name
)
70 sub_test_case("#extension") do
72 assert_equal("", @file_info.extension
)
76 @file_info.path
= "/a/b/c.d"
77 assert_equal("d", @file_info.extension
)
81 sub_test_case("#size") do
83 assert_equal(-1, @file_info.size
)
87 sub_test_case("#mtime") do
89 assert_equal(-1, @file_info.mtime
)
93 sub_test_case("#==") do
96 @other_file_info = Arrow
::FileInfo.new
99 test("all the properties are the same") do
101 @file_info == @other_file_info
105 test("the different type") do
106 @other_file_info.type
= Arrow
::FileType::FILE
108 @file_info != @other_file_info
112 test("the different path") do
113 @other_file_info.path
= "/a/b/c"
115 @file_info != @other_file_info
119 test("the different size") do
120 @other_file_info.size
= 42
122 @file_info != @other_file_info
126 test("the different mtime") do
127 @other_file_info.mtime
= Time
.now
.to_i
129 @file_info != @other_file_info
134 sub_test_case("#file?") do
136 @file_info.type
= :file
143 @file_info.type
= :dir
150 sub_test_case("#dir?") do
152 @file_info.type
= :dir
159 @file_info.type
= :file
167 assert_equal("FileInfo(FileType::Unknown, )",