mirror of
https://github.com/gonum/gonum.git
synced 2025-10-21 22:29:30 +08:00
unit: make tests parallel
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAbsorbedRadioactiveDose(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got AbsorbedRadioactiveDose
|
||||
err := got.From(AbsorbedRadioactiveDose(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestAbsorbedRadioactiveDose(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAbsorbedRadioactiveDoseFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value AbsorbedRadioactiveDose
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAcceleration(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Acceleration
|
||||
err := got.From(Acceleration(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestAcceleration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccelerationFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Acceleration
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAngle(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Angle
|
||||
err := got.From(Angle(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestAngle(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAngleFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Angle
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestArea(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Area
|
||||
err := got.From(Area(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestArea(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAreaFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Area
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCapacitance(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Capacitance
|
||||
err := got.From(Capacitance(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestCapacitance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCapacitanceFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Capacitance
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCharge(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Charge
|
||||
err := got.From(Charge(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestCharge(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChargeFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Charge
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestConductance(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Conductance
|
||||
err := got.From(Conductance(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestConductance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConductanceFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Conductance
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAvogadroFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
format string
|
||||
want string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBoltzmannFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
format string
|
||||
want string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestElectricConstantFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
format string
|
||||
want string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestFaradayFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
format string
|
||||
want string
|
||||
|
@@ -279,6 +279,7 @@ import (
|
||||
)
|
||||
|
||||
func Test{{.Name}}Format(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct{
|
||||
format string
|
||||
want string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGravitationalFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
format string
|
||||
want string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMagneticConstantFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
format string
|
||||
want string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPlanckFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
format string
|
||||
want string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCurrent(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Current
|
||||
err := got.From(Current(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestCurrent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCurrentFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Current
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDimless(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Dimless
|
||||
err := got.From(Dimless(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestDimless(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDimlessFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Dimless
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestEnergy(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Energy
|
||||
err := got.From(Energy(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestEnergy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnergyFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Energy
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestEquivalentRadioactiveDose(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got EquivalentRadioactiveDose
|
||||
err := got.From(EquivalentRadioactiveDose(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestEquivalentRadioactiveDose(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEquivalentRadioactiveDoseFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value EquivalentRadioactiveDose
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestForce(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Force
|
||||
err := got.From(Force(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestForce(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestForceFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Force
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestFrequency(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Frequency
|
||||
err := got.From(Frequency(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestFrequency(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFrequencyFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Frequency
|
||||
format string
|
||||
|
@@ -595,6 +595,7 @@ import (
|
||||
)
|
||||
|
||||
func Test{{.DimensionName}}(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got {{.DimensionName}}
|
||||
err := got.From({{.DimensionName}}(value).Unit())
|
||||
@@ -615,6 +616,7 @@ func Test{{.DimensionName}}(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test{{.DimensionName}}Format(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct{
|
||||
value {{.DimensionName}}
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestInductance(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Inductance
|
||||
err := got.From(Inductance(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestInductance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInductanceFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Inductance
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestLength(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Length
|
||||
err := got.From(Length(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestLength(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLengthFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Length
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestLuminousIntensity(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got LuminousIntensity
|
||||
err := got.From(LuminousIntensity(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestLuminousIntensity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLuminousIntensityFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value LuminousIntensity
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMagneticFlux(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got MagneticFlux
|
||||
err := got.From(MagneticFlux(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestMagneticFlux(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMagneticFluxFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value MagneticFlux
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMagneticFluxDensity(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got MagneticFluxDensity
|
||||
err := got.From(MagneticFluxDensity(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestMagneticFluxDensity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMagneticFluxDensityFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value MagneticFluxDensity
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMass(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Mass
|
||||
err := got.From(Mass(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestMass(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMassFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Mass
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMole(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Mole
|
||||
err := got.From(Mole(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestMole(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMoleFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Mole
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPower(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Power
|
||||
err := got.From(Power(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestPower(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPowerFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Power
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPressure(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Pressure
|
||||
err := got.From(Pressure(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestPressure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPressureFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Pressure
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestRadioactivity(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Radioactivity
|
||||
err := got.From(Radioactivity(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestRadioactivity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRadioactivityFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Radioactivity
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestResistance(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Resistance
|
||||
err := got.From(Resistance(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestResistance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResistanceFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Resistance
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTemperature(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Temperature
|
||||
err := got.From(Temperature(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestTemperature(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTemperatureFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Temperature
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Time
|
||||
err := got.From(Time(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTimeFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Time
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTorque(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Torque
|
||||
err := got.From(Torque(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestTorque(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTorqueFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Torque
|
||||
format string
|
||||
|
@@ -102,6 +102,7 @@ var formatTests = []struct {
|
||||
}
|
||||
|
||||
func TestFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, ts := range formatTests {
|
||||
if r := fmt.Sprintf(ts.format, ts.unit); r != ts.expect {
|
||||
t.Errorf("Format %q: got: %q expected: %q", ts.format, r, ts.expect)
|
||||
@@ -110,6 +111,7 @@ func TestFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGoStringFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
expect1 := `&unit.Unit{dimensions:unit.Dimensions{4:2, 7:-1}, value:6.62606957e-34}`
|
||||
expect2 := `&unit.Unit{dimensions:unit.Dimensions{7:-1, 4:2}, value:6.62606957e-34}`
|
||||
if r := fmt.Sprintf("%#v", New(6.62606957e-34, Dimensions{MassDim: 2, TimeDim: -1})); r != expect1 && r != expect2 {
|
||||
@@ -127,6 +129,7 @@ var initializationTests = []struct {
|
||||
}
|
||||
|
||||
func TestInitialization(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, ts := range initializationTests {
|
||||
if ts.expValue != ts.unit.value {
|
||||
t.Errorf("Value wrong on initialization: got: %v expected: %v", ts.unit.value, ts.expValue)
|
||||
@@ -159,6 +162,7 @@ var dimensionEqualityTests = []struct {
|
||||
}
|
||||
|
||||
func TestDimensionEquality(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, ts := range dimensionEqualityTests {
|
||||
if DimensionsMatch(ts.a, ts.b) != ts.shouldMatch {
|
||||
t.Errorf("Dimension comparison incorrect for case %s. got: %v, expected: %v", ts.name, !ts.shouldMatch, ts.shouldMatch)
|
||||
@@ -180,6 +184,7 @@ var operationTests = []struct {
|
||||
}
|
||||
|
||||
func TestOperations(t *testing.T) {
|
||||
t.Parallel()
|
||||
for i, test := range operationTests {
|
||||
var got Uniter
|
||||
if panics(func() { got = test.recvOp(test.param) }) {
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestVelocity(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Velocity
|
||||
err := got.From(Velocity(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestVelocity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVelocityFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Velocity
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestVoltage(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Voltage
|
||||
err := got.From(Voltage(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestVoltage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVoltageFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Voltage
|
||||
format string
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestVolume(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, value := range []float64{-1, 0, 1} {
|
||||
var got Volume
|
||||
err := got.From(Volume(value).Unit())
|
||||
@@ -32,6 +33,7 @@ func TestVolume(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVolumeFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range []struct {
|
||||
value Volume
|
||||
format string
|
||||
|
Reference in New Issue
Block a user