t / t0060-path-utils.shon commit revision --simplify-merges: use decoration instead of commit->util field (faf0156)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 David Reiss
   4#
   5
   6test_description='Test various path utilities'
   7
   8. ./test-lib.sh
   9
  10norm_abs() {
  11        test_expect_success "normalize absolute" \
  12        "test \$(test-path-utils normalize_absolute_path '$1') = '$2'"
  13}
  14
  15ancestor() {
  16        test_expect_success "longest ancestor" \
  17        "test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'"
  18}
  19
  20norm_abs "" /
  21norm_abs / /
  22norm_abs // /
  23norm_abs /// /
  24norm_abs /. /
  25norm_abs /./ /
  26norm_abs /./.. /
  27norm_abs /../. /
  28norm_abs /./../.// /
  29norm_abs /dir/.. /
  30norm_abs /dir/sub/../.. /
  31norm_abs /dir /dir
  32norm_abs /dir// /dir
  33norm_abs /./dir /dir
  34norm_abs /dir/. /dir
  35norm_abs /dir///./ /dir
  36norm_abs /dir//sub/.. /dir
  37norm_abs /dir/sub/../ /dir
  38norm_abs //dir/sub/../. /dir
  39norm_abs /dir/s1/../s2/ /dir/s2
  40norm_abs /d1/s1///s2/..//../s3/ /d1/s3
  41norm_abs /d1/s1//../s2/../../d2 /d2
  42norm_abs /d1/.../d2 /d1/.../d2
  43norm_abs /d1/..././../d2 /d1/d2
  44
  45ancestor / "" -1
  46ancestor / / -1
  47ancestor /foo "" -1
  48ancestor /foo : -1
  49ancestor /foo ::. -1
  50ancestor /foo ::..:: -1
  51ancestor /foo / 0
  52ancestor /foo /fo -1
  53ancestor /foo /foo -1
  54ancestor /foo /foo/ -1
  55ancestor /foo /bar -1
  56ancestor /foo /bar/ -1
  57ancestor /foo /foo/bar -1
  58ancestor /foo /foo:/bar/ -1
  59ancestor /foo /foo/:/bar/ -1
  60ancestor /foo /foo::/bar/ -1
  61ancestor /foo /:/foo:/bar/ 0
  62ancestor /foo /foo:/:/bar/ 0
  63ancestor /foo /:/bar/:/foo 0
  64ancestor /foo/bar "" -1
  65ancestor /foo/bar / 0
  66ancestor /foo/bar /fo -1
  67ancestor /foo/bar foo -1
  68ancestor /foo/bar /foo 4
  69ancestor /foo/bar /foo/ 4
  70ancestor /foo/bar /foo/ba -1
  71ancestor /foo/bar /:/fo 0
  72ancestor /foo/bar /foo:/foo/ba 4
  73ancestor /foo/bar /bar -1
  74ancestor /foo/bar /bar/ -1
  75ancestor /foo/bar /fo: -1
  76ancestor /foo/bar :/fo -1
  77ancestor /foo/bar /foo:/bar/ 4
  78ancestor /foo/bar /:/foo:/bar/ 4
  79ancestor /foo/bar /foo:/:/bar/ 4
  80ancestor /foo/bar /:/bar/:/fo 0
  81ancestor /foo/bar /:/bar/ 0
  82ancestor /foo/bar :://foo/. 4
  83ancestor /foo/bar :://foo/.:: 4
  84ancestor /foo/bar //foo/./::/bar 4
  85ancestor /foo/bar ::/bar -1
  86
  87test_done