file_spec.rb (2609B)
1 # Copyright, 2014, by Masahiro Sano. 2 # 3 # Permission is hereby granted, free of charge, to any person obtaining a copy 4 # of this software and associated documentation files (the "Software"), to deal 5 # in the Software without restriction, including without limitation the rights 6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 # copies of the Software, and to permit persons to whom the Software is 8 # furnished to do so, subject to the following conditions: 9 # 10 # The above copyright notice and this permission notice shall be included in 11 # all copies or substantial portions of the Software. 12 # 13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 # THE SOFTWARE. 20 21 describe File do 22 let(:file_list) { Index.new.parse_translation_unit(fixture_path("list.c")).file(fixture_path("list.c")) } 23 let(:file_docs) { Index.new.parse_translation_unit(fixture_path("docs.c")).file(fixture_path("docs.h")) } 24 25 it "can be obtained from a translation unit" do 26 expect(file_list).to be_kind_of(FFI::Clang::File) 27 end 28 29 describe "#name" do 30 let(:name) { file_list.name } 31 32 it 'returns its file name' do 33 expect(name).to be_kind_of(String) 34 expect(name).to eq(fixture_path("list.c")) 35 end 36 end 37 38 describe "#to_s" do 39 let(:name) { file_list.to_s } 40 41 it 'returns its file name' do 42 expect(name).to be_kind_of(String) 43 expect(name).to eq(fixture_path("list.c")) 44 end 45 end 46 47 describe "#time" do 48 let(:time) { file_list.time } 49 50 it 'returns file time' do 51 expect(time).to be_kind_of(Time) 52 end 53 end 54 55 describe "#include_guarded?" do 56 it 'returns false if included file is notguarded' do 57 expect(file_list.include_guarded?).to be false 58 end 59 60 it 'returns true if included file is guarded' do 61 expect(file_docs.include_guarded?).to be true 62 end 63 end 64 65 describe "#device" do 66 it 'returns device from CXFileUniqueID' do 67 expect(file_list.device).to be_kind_of(Integer) 68 end 69 end 70 71 describe "#inode" do 72 it 'returns inode from CXFileUniqueID' do 73 expect(file_list.inode).to be_kind_of(Integer) 74 end 75 end 76 77 describe "#modification" do 78 it 'returns modification time as Time from CXFileUniqueID' do 79 expect(file_list.modification).to be_kind_of(Time) 80 end 81 end 82 end