t / t0081-line-buffer.shon commit Merge branch 'jt/fetch-no-redundant-tag-fetch-map' (06cfa9f)
   1#!/bin/sh
   2
   3test_description="Test the svn importer's input handling routines.
   4
   5These tests provide some simple checks that the line_buffer API
   6behaves as advertised.
   7
   8While at it, check that input of newlines and null bytes are handled
   9correctly.
  10"
  11. ./test-lib.sh
  12
  13test_expect_success 'hello world' '
  14        echo ">HELLO" >expect &&
  15        test-line-buffer <<-\EOF >actual &&
  16        binary 6
  17        HELLO
  18        EOF
  19        test_cmp expect actual
  20'
  21
  22test_expect_success '0-length read, send along greeting' '
  23        echo ">HELLO" >expect &&
  24        test-line-buffer <<-\EOF >actual &&
  25        binary 0
  26        copy 6
  27        HELLO
  28        EOF
  29        test_cmp expect actual
  30'
  31
  32test_expect_success !MINGW 'read from file descriptor' '
  33        rm -f input &&
  34        echo hello >expect &&
  35        echo hello >input &&
  36        echo copy 6 |
  37        test-line-buffer "&4" 4<input >actual &&
  38        test_cmp expect actual
  39'
  40
  41test_expect_success 'skip, copy null byte' '
  42        echo Q | q_to_nul >expect &&
  43        q_to_nul <<-\EOF | test-line-buffer >actual &&
  44        skip 2
  45        Q
  46        copy 2
  47        Q
  48        EOF
  49        test_cmp expect actual
  50'
  51
  52test_expect_success 'read null byte' '
  53        echo ">QhelloQ" | q_to_nul >expect &&
  54        q_to_nul <<-\EOF | test-line-buffer >actual &&
  55        binary 8
  56        QhelloQ
  57        EOF
  58        test_cmp expect actual
  59'
  60
  61test_expect_success 'long reads are truncated' '
  62        echo ">foo" >expect &&
  63        test-line-buffer <<-\EOF >actual &&
  64        binary 5
  65        foo
  66        EOF
  67        test_cmp expect actual
  68'
  69
  70test_expect_success 'long copies are truncated' '
  71        printf "%s\n" ">" foo >expect &&
  72        test-line-buffer <<-\EOF >actual &&
  73        binary 1
  74
  75        copy 5
  76        foo
  77        EOF
  78        test_cmp expect actual
  79'
  80
  81test_expect_success 'long binary reads are truncated' '
  82        echo ">foo" >expect &&
  83        test-line-buffer <<-\EOF >actual &&
  84        binary 5
  85        foo
  86        EOF
  87        test_cmp expect actual
  88'
  89
  90test_done