@@ -74,18 +74,31 @@ func Test_readfile_binary()
7474 new
7575 call setline (1 , [' one' , ' two' , ' three' ])
7676 setlocal ff = dos
77- silent write XReadfile
78- let lines = ' XReadfile ' - >readfile ()
77+ silent write XReadfile_bin
78+ let lines = ' XReadfile_bin ' - >readfile ()
7979 call assert_equal ([' one' , ' two' , ' three' ], lines )
80- let lines = readfile (' XReadfile ' , ' ' , 2 )
80+ let lines = readfile (' XReadfile_bin ' , ' ' , 2 )
8181 call assert_equal ([' one' , ' two' ], lines )
82- let lines = readfile (' XReadfile ' , ' b' )
82+ let lines = readfile (' XReadfile_bin ' , ' b' )
8383 call assert_equal ([" one\r " , " two\r " , " three\r " , " " ], lines )
84- let lines = readfile (' XReadfile ' , ' b' , 2 )
84+ let lines = readfile (' XReadfile_bin ' , ' b' , 2 )
8585 call assert_equal ([" one\r " , " two\r " ], lines )
8686
8787 bwipe!
88- call delete (' XReadfile' )
88+ call delete (' XReadfile_bin' )
89+ endfunc
90+
91+ func Test_readfile_bom ()
92+ call writefile ([" \ufeff FOO" , " FOO\ufeff BAR" ], ' XReadfile_bom' )
93+ call assert_equal ([' FOO' , ' FOOBAR' ], readfile (' XReadfile_bom' ))
94+ call delete (' XReadfile_bom' )
95+ endfunc
96+
97+ func Test_readfile_max ()
98+ call writefile (range (1 , 4 ), ' XReadfile_max' )
99+ call assert_equal ([' 1' , ' 2' ], readfile (' XReadfile_max' , ' ' , 2 ))
100+ call assert_equal ([' 3' , ' 4' ], readfile (' XReadfile_max' , ' ' , -2 ))
101+ call delete (' XReadfile_max' )
89102endfunc
90103
91104func Test_let_errmsg ()
0 commit comments