Skip to content

Commit 4508c7f

Browse files
committed
Fixed Some Issues With Printing ConstrSense objects
1 parent 1b7c77f commit 4508c7f

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

testing/optim/var_vector_test.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,11 @@ func TestVarVector_Eq2(t *testing.T) {
336336

337337
// Verify that constraint can be created with no issues.
338338
_, err := vv1.Eq(badRHS)
339-
expectedError := fmt.Sprintf("The Eq() method for VarVector is not implemented yet for type %T!", badRHS)
339+
expectedError := fmt.Sprintf(
340+
"The VarVector.Comparison (%v) method is not implemented yet for type %T!",
341+
optim.SenseEqual,
342+
badRHS,
343+
)
340344
if !strings.Contains(err.Error(), expectedError) {
341345
t.Errorf("Expected error \"%v\"; received \"%v\"", expectedError, err)
342346
}
@@ -1066,16 +1070,22 @@ func TestVarVector_GreaterEq1(t *testing.T) {
10661070

10671071
// Compare
10681072
_, err := vec1.GreaterEq(kv1)
1069-
if !strings.Contains(
1070-
err.Error(),
1071-
fmt.Sprintf(
1072-
"The two inputs to comparison '%v' must have the same dimension, but #1 has dimension %v and #2 has dimension %v!",
1073-
optim.SenseGreaterThanEqual,
1074-
vec1.Len(),
1075-
kv1.Len(),
1076-
),
1077-
) {
1078-
t.Errorf("Unexpected error when comparing two vectors: %v", err)
1073+
expectedError := fmt.Sprintf(
1074+
"The two inputs to comparison '%v' must have the same dimension, but #1 has dimension %v and #2 has dimension %v!",
1075+
optim.ConstrSense(optim.SenseGreaterThanEqual),
1076+
vec1.Len(),
1077+
kv1.Len(),
1078+
)
1079+
if err == nil {
1080+
t.Errorf("No error was thrown, but we expected one!")
1081+
} else {
1082+
if !strings.Contains(
1083+
err.Error(),
1084+
expectedError,
1085+
) {
1086+
t.Errorf("Unexpected error when comparing two vectors: %v \n expected %v", err, expectedError)
1087+
}
1088+
10791089
}
10801090

10811091
}

testing/optim/var_vector_transpose_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ func TestVarVectorTranspose_Comparison5(t *testing.T) {
530530
err.Error(),
531531
fmt.Sprintf(
532532
"The two inputs to comparison '%v' must have the same dimension, but #1 has dimension %v and #2 has dimension %v!",
533-
optim.SenseGreaterThanEqual,
533+
optim.ConstrSense(optim.SenseGreaterThanEqual),
534534
vec1.Len(),
535535
vec2.Len(),
536536
),
@@ -1137,7 +1137,7 @@ func TestVarVectorTranspose_LessEq1(t *testing.T) {
11371137
err.Error(),
11381138
fmt.Sprintf(
11391139
"The two inputs to comparison '%v' must have the same dimension, but #1 has dimension %v and #2 has dimension %v!",
1140-
optim.SenseLessThanEqual,
1140+
optim.ConstrSense(optim.SenseLessThanEqual),
11411141
vec1.Len(),
11421142
kv2.Len(),
11431143
),

0 commit comments

Comments
 (0)