Initial commit

This commit is contained in:
2024-12-31 01:27:53 -05:00
commit b3913d8078
25 changed files with 2477 additions and 0 deletions

74
error_test.go Normal file
View File

@@ -0,0 +1,74 @@
package camfish
import "testing"
func TestConfigError (test *testing.T) {
err := ConfigError {
File: "example.conf",
Key: "some-key",
Line: 6,
Column: 20,
Err: ErrNotFound,
}
str := err.Error()
test.Log(str)
if str != "example.conf[some-key]:6:20: not found" {
test.Fatal("not equal")
}
unwrapped := err.Unwrap()
test.Log(unwrapped)
if unwrapped!= ErrNotFound {
test.Fatal("not equal")
}
err = ConfigError {
File: "example.conf",
Line: 6,
Column: 20,
Err: ErrNotFound,
}
str = err.Error()
test.Log(str)
if str != "example.conf:6:20: not found" {
test.Fatal("not equal")
}
err = ConfigError {
Key: "some-key",
Column: 20,
Err: ErrNotFound,
}
str = err.Error()
test.Log(str)
if str != "[some-key]: not found" {
test.Fatal("not equal")
}
err = ConfigError {
File: "example.conf",
Key: "some-key",
Line: 20,
Err: ErrNotFound,
}
str = err.Error()
test.Log(str)
if str != "example.conf[some-key]:20: not found" {
test.Fatal("not equal")
}
err = ConfigError {
Err: ErrNotFound,
}
str = err.Error()
test.Log(str)
if str != "not found" {
test.Fatal("not equal")
}
err = ConfigError { }
str = err.Error()
test.Log(str)
if str != "configuration error" {
test.Fatal("not equal")
}
}