From 91e663c0f0ec4e1e61a2493f6ab08850cd2e5a2e Mon Sep 17 00:00:00 2001 From: nytpu Date: Tue, 16 Mar 2021 10:20:31 -0600 Subject: add command parsing --- comitium_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 comitium_test.go (limited to 'comitium_test.go') diff --git a/comitium_test.go b/comitium_test.go new file mode 100644 index 0000000..287975a --- /dev/null +++ b/comitium_test.go @@ -0,0 +1,31 @@ +// Copyright (C) 2021 nytpu +// SPDX-License-Identifier: AGPL-3.0-or-later +// For more license details, see LICENSE or . + +package main + +import ( + "testing" +) + +func TestVerifyPath(t *testing.T) { + given := []string{ + "~////../hello-world////", + "/home/~/../test/../..", + "/test/torture/../../../../test/./././torture/./0011/", + ".local/share/comitium/", + "/home/test/.local/share/comitium", + } + want := []string{ + "/home/hello-world", + "/", + "/test/torture/0011", + ".local/share/comitium", + "/home/test/.local/share/comitium", + } + for i, v := range given { + if result := verifyPath(v); result != want[i] { + t.Fatalf(`verifyPath("%v") = %v, want %v`, v, result, want[i]) + } + } +} -- cgit v1.2.3