13ac735b550777447c2969e56b9973306aad434c
   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 5
  11        HELLO
  12        EOF
  13        test_cmp expect actual
  14'
  15
  16test_expect_success '0-length read, send along greeting' '
  17        printf "%s\n" "" HELLO >expect &&
  18        test-line-buffer <<-\EOF >actual &&
  19        read 0
  20
  21        copy 5
  22        HELLO
  23        EOF
  24        test_cmp expect actual
  25'
  26
  27test_expect_success 'buffer_read_string copes with trailing null byte' '
  28        echo >expect &&
  29        q_to_nul <<-\EOF | test-line-buffer >actual &&
  30        read 1
  31        Q
  32        EOF
  33        test_cmp expect actual
  34'
  35
  36test_expect_success '0-length read, copy null byte' '
  37        printf "%s\n" "" Q | q_to_nul >expect &&
  38        q_to_nul <<-\EOF | test-line-buffer >actual &&
  39        read 0
  40
  41        copy 1
  42        Q
  43        EOF
  44        test_cmp expect actual
  45'
  46
  47test_expect_success 'long reads are truncated' '
  48        printf "%s\n" foo "" >expect &&
  49        test-line-buffer <<-\EOF >actual &&
  50        read 5
  51        foo
  52        EOF
  53        test_cmp expect actual
  54'
  55
  56test_expect_success 'long copies are truncated' '
  57        printf "%s\n" "" foo >expect &&
  58        test-line-buffer <<-\EOF >actual &&
  59        read 0
  60
  61        copy 5
  62        foo
  63        EOF
  64        test_cmp expect actual
  65'
  66
  67test_done