mat: avoid hard coding expected output that depends on weak promises

Note that the tests here are less tautological than they first appear. The
expectations are printed with %#v on a *Dense, while the tests are printed
with %#v via a formatter.
This commit is contained in:
Dan Kortschak
2018-09-12 18:09:34 +09:30
committed by Dan Kortschak
parent a809dafcb1
commit fa04bde682

View File

@@ -26,7 +26,7 @@ func TestFormat(t *testing.T) {
[]rp{
{"%v", "⎡0 0 0⎤\n⎢0 0 0⎥\n⎣0 0 0⎦"},
{"% f", "⎡. . .⎤\n⎢. . .⎥\n⎣. . .⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:3, Cols:3, Data:[]float64{0, 0, 0, 0, 0, 0, 0, 0, 0}, Stride:3}, capRows:3, capCols:3}"},
{"%#v", fmt.Sprintf("%#v", NewDense(3, 3, nil))},
{"%s", "%!s(*mat.Dense=Dims(3, 3))"},
},
},
@@ -35,7 +35,7 @@ func TestFormat(t *testing.T) {
[]rp{
{"%v", "⎡1 1 1⎤\n⎢1 1 1⎥\n⎣1 1 1⎦"},
{"% f", "⎡1 1 1⎤\n⎢1 1 1⎥\n⎣1 1 1⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:3, Cols:3, Data:[]float64{1, 1, 1, 1, 1, 1, 1, 1, 1}, Stride:3}, capRows:3, capCols:3}"},
{"%#v", fmt.Sprintf("%#v", NewDense(3, 3, []float64{1, 1, 1, 1, 1, 1, 1, 1, 1}))},
},
},
{
@@ -43,7 +43,7 @@ func TestFormat(t *testing.T) {
[]rp{
{"%v", "⎡1 1 1⎤\n\t⎢1 1 1⎥\n\t⎣1 1 1⎦"},
{"% f", "⎡1 1 1⎤\n\t⎢1 1 1⎥\n\t⎣1 1 1⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:3, Cols:3, Data:[]float64{1, 1, 1, 1, 1, 1, 1, 1, 1}, Stride:3}, capRows:3, capCols:3}"},
{"%#v", fmt.Sprintf("%#v", NewDense(3, 3, []float64{1, 1, 1, 1, 1, 1, 1, 1, 1}))},
},
},
{
@@ -51,7 +51,7 @@ func TestFormat(t *testing.T) {
[]rp{
{"%v", "⎡1 0 0⎤\n⎢0 1 0⎥\n⎣0 0 1⎦"},
{"% f", "⎡1 . .⎤\n⎢. 1 .⎥\n⎣. . 1⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:3, Cols:3, Data:[]float64{1, 0, 0, 0, 1, 0, 0, 0, 1}, Stride:3}, capRows:3, capCols:3}"},
{"%#v", fmt.Sprintf("%#v", NewDense(3, 3, []float64{1, 0, 0, 0, 1, 0, 0, 0, 1}))},
},
},
{
@@ -59,7 +59,7 @@ func TestFormat(t *testing.T) {
[]rp{
{"%v", "⎡1 2 3⎤\n⎣4 5 6⎦"},
{"% f", "⎡1 2 3⎤\n⎣4 5 6⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:2, Cols:3, Data:[]float64{1, 2, 3, 4, 5, 6}, Stride:3}, capRows:2, capCols:3}"},
{"%#v", fmt.Sprintf("%#v", NewDense(2, 3, []float64{1, 2, 3, 4, 5, 6}))},
},
},
{
@@ -67,7 +67,7 @@ func TestFormat(t *testing.T) {
[]rp{
{"%v", "⎡1 2⎤\n⎢3 4⎥\n⎣5 6⎦"},
{"% f", "⎡1 2⎤\n⎢3 4⎥\n⎣5 6⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:3, Cols:2, Data:[]float64{1, 2, 3, 4, 5, 6}, Stride:2}, capRows:3, capCols:2}"},
{"%#v", fmt.Sprintf("%#v", NewDense(3, 2, []float64{1, 2, 3, 4, 5, 6}))},
},
},
{
@@ -80,7 +80,7 @@ func TestFormat(t *testing.T) {
{"%v", "⎡ 0 1 1.4142135623730951⎤\n⎣1.7320508075688772 2 2.23606797749979⎦"},
{"%.2f", "⎡0.00 1.00 1.41⎤\n⎣1.73 2.00 2.24⎦"},
{"% f", "⎡ . 1 1.4142135623730951⎤\n⎣1.7320508075688772 2 2.23606797749979⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:2, Cols:3, Data:[]float64{0, 1, 1.4142135623730951, 1.7320508075688772, 2, 2.23606797749979}, Stride:3}, capRows:2, capCols:3}"},
{"%#v", fmt.Sprintf("%#v", NewDense(2, 3, []float64{0, 1, 1.4142135623730951, 1.7320508075688772, 2, 2.23606797749979}))},
},
},
{
@@ -93,7 +93,7 @@ func TestFormat(t *testing.T) {
{"%v", "⎡ 0 1⎤\n⎢1.4142135623730951 1.7320508075688772⎥\n⎣ 2 2.23606797749979⎦"},
{"%.2f", "⎡0.00 1.00⎤\n⎢1.41 1.73⎥\n⎣2.00 2.24⎦"},
{"% f", "⎡ . 1⎤\n⎢1.4142135623730951 1.7320508075688772⎥\n⎣ 2 2.23606797749979⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:3, Cols:2, Data:[]float64{0, 1, 1.4142135623730951, 1.7320508075688772, 2, 2.23606797749979}, Stride:2}, capRows:3, capCols:2}"},
{"%#v", fmt.Sprintf("%#v", NewDense(3, 2, []float64{0, 1, 1.4142135623730951, 1.7320508075688772, 2, 2.23606797749979}))},
},
},
{
@@ -106,7 +106,7 @@ func TestFormat(t *testing.T) {
{"%v", "⎡ 0 1 1.4142135623730951⎤\n⎣1.7320508075688772 2 2.23606797749979⎦"},
{"%.2f", "⎡0.00 1.00 1.41⎤\n⎣1.73 2.00 2.24⎦"},
{"% f", "⎡ . 1 1.4142135623730951⎤\n⎣1.7320508075688772 2 2.23606797749979⎦"},
{"%#v", "&mat.Dense{mat:blas64.General{Rows:2, Cols:3, Data:[]float64{0, 1, 1.4142135623730951, 1.7320508075688772, 2, 2.23606797749979}, Stride:3}, capRows:2, capCols:3}"},
{"%#v", fmt.Sprintf("%#v", NewDense(2, 3, []float64{0, 1, 1.4142135623730951, 1.7320508075688772, 2, 2.23606797749979}))},
},
},
{