blob: 664308741eda4252b94b97aedd9df0dd08719a60 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package codifier
import (
"fmt"
"testing"
)
func TestResolve(t *testing.T) {
tests := []struct {
base, home, cwd, path, want string
}{
{"", "", "", "/f", "/f"},
{"", "", "", "//f", "f"},
{"", "", "", "~f", "f"},
{"", "", "", "f", "f"},
{"b", "h", "c", "/f", "/f"},
{"b", "h", "c", "//f", "b/f"},
{"b", "h", "c", "///f", "b/f"},
{"b", "h", "c", "~f", "h/f"},
{"b", "h", "c", "f", "c/f"},
{"b", "h", "c", "", "c"},
}
for i, tt := range tests {
testname := fmt.Sprintf("(%q, %q, %q, %q)[%d]", tt.base, tt.home, tt.cwd, tt.path, i)
t.Run(testname, func(t *testing.T) {
got := resolve(tt.base, tt.home, tt.cwd, tt.path)
if got != tt.want {
t.Errorf("want %q, got %q", tt.want, got)
}
})
}
}