t / t0016-oidmap.shon commit Merge branch 'js/visual-studio' (c62bc49)
   1#!/bin/sh
   2
   3test_description='test oidmap'
   4. ./test-lib.sh
   5
   6# This purposefully is very similar to t0011-hashmap.sh
   7
   8test_oidmap () {
   9        echo "$1" | test-tool oidmap $3 >actual &&
  10        echo "$2" >expect &&
  11        test_cmp expect actual
  12}
  13
  14
  15test_expect_success 'setup' '
  16
  17        test_commit one &&
  18        test_commit two &&
  19        test_commit three &&
  20        test_commit four
  21
  22'
  23
  24test_expect_success 'put' '
  25
  26test_oidmap "put one 1
  27put two 2
  28put invalidOid 4
  29put three 3" "NULL
  30NULL
  31Unknown oid: invalidOid
  32NULL"
  33
  34'
  35
  36test_expect_success 'replace' '
  37
  38test_oidmap "put one 1
  39put two 2
  40put three 3
  41put invalidOid 4
  42put two deux
  43put one un" "NULL
  44NULL
  45NULL
  46Unknown oid: invalidOid
  472
  481"
  49
  50'
  51
  52test_expect_success 'get' '
  53
  54test_oidmap "put one 1
  55put two 2
  56put three 3
  57get two
  58get four
  59get invalidOid
  60get one" "NULL
  61NULL
  62NULL
  632
  64NULL
  65Unknown oid: invalidOid
  661"
  67
  68'
  69
  70test_expect_success 'remove' '
  71
  72test_oidmap "put one 1
  73put two 2
  74put three 3
  75remove one
  76remove two
  77remove invalidOid
  78remove four" "NULL
  79NULL
  80NULL
  811
  822
  83Unknown oid: invalidOid
  84NULL"
  85
  86'
  87
  88test_expect_success 'iterate' '
  89        test-tool oidmap >actual.raw <<-\EOF &&
  90        put one 1
  91        put two 2
  92        put three 3
  93        iterate
  94        EOF
  95
  96        # sort "expect" too so we do not rely on the order of particular oids
  97        sort >expect <<-EOF &&
  98        NULL
  99        NULL
 100        NULL
 101        $(git rev-parse one) 1
 102        $(git rev-parse two) 2
 103        $(git rev-parse three) 3
 104        EOF
 105
 106        sort <actual.raw >actual &&
 107        test_cmp expect actual
 108'
 109
 110test_done