t / t9002-column.shon commit Git 2.15 (cb5918a)
   1#!/bin/sh
   2
   3test_description='git column'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup' '
   7        cat >lista <<\EOF
   8one
   9two
  10three
  11four
  12five
  13six
  14seven
  15eight
  16nine
  17ten
  18eleven
  19EOF
  20'
  21
  22test_expect_success 'never' '
  23        git column --indent=Z --mode=never <lista >actual &&
  24        test_cmp lista actual
  25'
  26
  27test_expect_success 'always' '
  28        cat >expected <<\EOF &&
  29Zone
  30Ztwo
  31Zthree
  32Zfour
  33Zfive
  34Zsix
  35Zseven
  36Zeight
  37Znine
  38Zten
  39Zeleven
  40EOF
  41        git column --indent=Z --mode=plain <lista >actual &&
  42        test_cmp expected actual
  43'
  44
  45test_expect_success '80 columns' '
  46        cat >expected <<\EOF &&
  47one    two    three  four   five   six    seven  eight  nine   ten    eleven
  48EOF
  49        COLUMNS=80 git column --mode=column <lista >actual &&
  50        test_cmp expected actual
  51'
  52
  53cat >expected <<\EOF
  54one
  55two
  56three
  57four
  58five
  59six
  60seven
  61eight
  62nine
  63ten
  64eleven
  65EOF
  66
  67test_expect_success COLUMNS_CAN_BE_1 'COLUMNS = 1' '
  68        COLUMNS=1 git column --mode=column <lista >actual &&
  69        test_cmp expected actual
  70'
  71
  72test_expect_success 'width = 1' '
  73        git column --mode=column --width=1 <lista >actual &&
  74        test_cmp expected actual
  75'
  76
  77COLUMNS=20
  78export COLUMNS
  79
  80test_expect_success '20 columns' '
  81        cat >expected <<\EOF &&
  82one    seven
  83two    eight
  84three  nine
  85four   ten
  86five   eleven
  87six
  88EOF
  89        git column --mode=column <lista >actual &&
  90        test_cmp expected actual
  91'
  92
  93test_expect_success '20 columns, nodense' '
  94        cat >expected <<\EOF &&
  95one    seven
  96two    eight
  97three  nine
  98four   ten
  99five   eleven
 100six
 101EOF
 102        git column --mode=column,nodense < lista > actual &&
 103        test_cmp expected actual
 104'
 105
 106test_expect_success '20 columns, dense' '
 107        cat >expected <<\EOF &&
 108one   five  nine
 109two   six   ten
 110three seven eleven
 111four  eight
 112EOF
 113        git column --mode=column,dense < lista > actual &&
 114        test_cmp expected actual
 115'
 116
 117test_expect_success '20 columns, padding 2' '
 118        cat >expected <<\EOF &&
 119one     seven
 120two     eight
 121three   nine
 122four    ten
 123five    eleven
 124six
 125EOF
 126        git column --mode=column --padding 2 <lista >actual &&
 127        test_cmp expected actual
 128'
 129
 130test_expect_success '20 columns, indented' '
 131        cat >expected <<\EOF &&
 132  one    seven
 133  two    eight
 134  three  nine
 135  four   ten
 136  five   eleven
 137  six
 138EOF
 139        git column --mode=column --indent="  " <lista >actual &&
 140        test_cmp expected actual
 141'
 142
 143test_expect_success '20 columns, row first' '
 144        cat >expected <<\EOF &&
 145one    two
 146three  four
 147five   six
 148seven  eight
 149nine   ten
 150eleven
 151EOF
 152        git column --mode=row <lista >actual &&
 153        test_cmp expected actual
 154'
 155
 156test_expect_success '20 columns, row first, nodense' '
 157        cat >expected <<\EOF &&
 158one    two
 159three  four
 160five   six
 161seven  eight
 162nine   ten
 163eleven
 164EOF
 165        git column --mode=row,nodense <lista >actual &&
 166        test_cmp expected actual
 167'
 168
 169test_expect_success '20 columns, row first, dense' '
 170        cat >expected <<\EOF &&
 171one   two    three
 172four  five   six
 173seven eight  nine
 174ten   eleven
 175EOF
 176        git column --mode=row,dense <lista >actual &&
 177        test_cmp expected actual
 178'
 179
 180test_done