68d616399548effd6285d26278eee29aa33f245d
   1#!/bin/sh
   2
   3test_description="Test the svn importer's input handling routines.
   4"
   5. ./test-lib.sh
   6
   7test_expect_success 'read greeting' '
   8        echo HELLO >expect &&
   9        test-line-buffer <<-\EOF >actual &&
  10        read 6
  11        HELLO
  12        EOF
  13        test_cmp expect actual
  14'
  15
  16test_expect_success '0-length read, send along greeting' '
  17        echo HELLO >expect &&
  18        test-line-buffer <<-\EOF >actual &&
  19        read 0
  20        copy 6
  21        HELLO
  22        EOF
  23        test_cmp expect actual
  24'
  25
  26test_expect_success 'buffer_read_string copes with null byte' '
  27        >expect &&
  28        q_to_nul <<-\EOF | test-line-buffer >actual &&
  29        read 2
  30        Q
  31        EOF
  32        test_cmp expect actual
  33'
  34
  35test_expect_success 'skip, copy null byte' '
  36        echo Q | q_to_nul >expect &&
  37        q_to_nul <<-\EOF | test-line-buffer >actual &&
  38        skip 2
  39        Q
  40        copy 2
  41        Q
  42        EOF
  43        test_cmp expect actual
  44'
  45
  46test_expect_success 'long reads are truncated' '
  47        echo foo >expect &&
  48        test-line-buffer <<-\EOF >actual &&
  49        read 5
  50        foo
  51        EOF
  52        test_cmp expect actual
  53'
  54
  55test_expect_success 'long copies are truncated' '
  56        printf "%s\n" "" foo >expect &&
  57        test-line-buffer <<-\EOF >actual &&
  58        read 1
  59
  60        copy 5
  61        foo
  62        EOF
  63        test_cmp expect actual
  64'
  65
  66test_done