github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/test_messages.go (about) 1 package lang 2 3 /* 4 This test library relates to the testing framework within the murex 5 language itself rather than Go's test framework within the murex project. 6 7 The naming convention here is basically the inverse of Go's test naming 8 convention. ie Go source files will be named "test_unit.go" (because 9 calling it unit_test.go would mean it's a Go test rather than murex test) 10 and the code is named UnitTestPlans (etc) rather than TestUnitPlans (etc) 11 because the latter might suggest they would be used by `go test`. This 12 naming convention is a little counterintuitive but it at least avoids 13 naming conflicts with `go test`. 14 */ 15 16 import "fmt" 17 18 // func tMsgPassed() string { return "All test conditions were met" } 19 func tMsgPassed() string { return "-" } 20 func tMsgStdout(property string, stdout []byte) string { 21 return fmt.Sprintf("%s output: %s", property, stdout) 22 } 23 24 func tMsgStderr(property string, stdout []byte) string { 25 return fmt.Sprintf("%s returned an error: %s", property, stdout) 26 } 27 28 func tMsgReadErr(stdType string, property string, err error) string { 29 return fmt.Sprintf("Error reading %s from %s: %s", stdType, property, err) 30 } 31 func tMsgWriteErr(property string, err error) string { 32 return fmt.Sprintf("Error writing to stdin for %s: %s", property, err) 33 } 34 35 func tMsgUnmarshalErr(property string, dt string, err error) string { 36 return fmt.Sprintf("Error unmarshalling `%s` for %s: %s", dt, property, err) 37 } 38 func tMsgDataFormatValid(property string, dt string, v interface{}) string { 39 return fmt.Sprintf("%s data format valid. Data-type `%s` unmarshalled as `%T`", property, dt, v) 40 } 41 func tMsgDataFormatInvalid(property string, dt string, v interface{}) string { 42 return fmt.Sprintf("%s data format invalid. Data-type `%s` unmarshalled as `%T`", property, dt, v) 43 } 44 45 func tMsgCompileErr(property string, err error) string { 46 return fmt.Sprintf("%s failed to compile: %s", property, err) 47 } 48 func tMsgNoneZeroExit(property string, exitnum int) string { 49 return fmt.Sprintf("%s exit num non-zero: %d", property, exitnum) 50 } 51 52 func tMsgExitNumMismatch(exp int, act int) string { 53 return fmt.Sprintf("ExitNum mismatch. Exp: %d, act: %d", exp, act) 54 } 55 func tMsgExitNumMatch() string { 56 return "ExitNum matches expected" 57 } 58 59 func tMsgExitNumNotZero(property string, exitnum int) string { 60 return fmt.Sprintf("%s failed the test with an exit num of %d", property, exitnum) 61 } 62 func tMsgExitNumZero(property string) string { 63 return fmt.Sprintf("%s passed the test. Returned true", property) 64 } 65 66 func tMsgDataTypeMismatch(stdType string, act string) string { 67 return fmt.Sprintf("Data-type mismatch on %s. act: '%s'", stdType, act) 68 } 69 func tMsgDataTypeMatch(stdType string) string { 70 return fmt.Sprintf("Expected data-type matched on %s", stdType) 71 } 72 73 func tMsgStringMismatch(property string, std []byte) string { 74 return fmt.Sprintf("%s string mismatch. act: '%s'", property, std) 75 } 76 func tMsgStringMatch(property string) string { 77 return fmt.Sprintf("%s matches expected string", property) 78 } 79 80 func tMsgRegexCompileErr(property string, err error) string { 81 return fmt.Sprintf("%s could not compile: %s", property, err) 82 } 83 func tMsgRegexMismatch(property string, std []byte) string { 84 return fmt.Sprintf("%s expression did not match. act: '%s'", property, std) 85 } 86 func tMsgRegexMatch(property string) string { 87 return fmt.Sprintf("%s matches expected regex expression", property) 88 } 89 90 func tMsgGtEqFail(property string, length, comparison int) string { 91 return fmt.Sprintf("%s length (%d) is less than %d", property, length, comparison) 92 } 93 func tMsgGtEqMatch(property string, length, comparison int) string { 94 return fmt.Sprintf("%s length (%d) is greater than or equal to %d", property, length, comparison) 95 }