splittable: klare Fehler für -0 und mehr als 676 Stücke

This commit is contained in:
wkh
2026-10-11 23:23:37 +02:00
parent 1c66773ff4
commit b11e3da453
6 changed files with 36 additions and 4 deletions
+15
View File
@@ -5,6 +5,21 @@ require 'pty'
require_relative '../lib/rdb'
class SelectionTest < RdbCase
def test_splittable_pieces_and_errors
out, = run3('splittable', '-4', 'inventory')
assert_equal 4, data(File.read(File.join(@dir, 'inventoryaa'))).size
assert_equal 3, data(File.read(File.join(@dir, 'inventoryab'))).size
assert_includes File.read(File.join(@dir, 'inventoryab')), "Item\tAmount"
_o, err, st = run3('splittable', '-0', 'inventory')
refute st.success?
assert_match(/usage/, err)
write('big', "N\n-\n#{(1..700).to_a.join("\n")}\n")
_o, err, st = run3('splittable', '-1', 'big')
refute st.success?
assert_match(/only 676 names/, err)
assert_empty Dir[File.join(@dir, 'bigaa')] # nothing is written when it cannot all be written
end
def test_record_zero_and_one_are_the_first_and_negatives_count_from_the_end
{ '0' => '1', '1' => '1', '2' => '3', '3' => '6', '-1' => '6', '-2' => '3', '-3' => '1', '+2' => '3' }.each do |n, item|
assert_equal [[item]], data(rdb('record', n, file: 'owners')).map { |r| r.first(1) }, "record #{n}"