func TestQty(t *testing.T) { m := mat1() assert.Eq(t, m.Qty(), qty1) var qty float64 = 3 m.SetQty(qty) assert.Eq(t, m.Qty(), qty) }
func TestExtractMass_Bad(t *testing.T) { m := mat1() cmp := m.Comp var qty float64 = 5.1 _, err := m.ExtractMass(qty) assert.Err(t, err).Fatal() assert.Eq(t, m.Qty(), qty1) assert.Eq(t, m.Comp, cmp) }
func TestAbsorb(t *testing.T) { m1 := mat1() cmp := m1.Comp m3 := mat3() m1.Absorb(m3) assert.Eq(t, m1.Qty(), qty1+qty3) assert.Eq(t, m3.Qty(), zero) assert.Ne(t, m1.Comp, cmp) }
func TestExtractComp_Bad(t *testing.T) { m := mat1() mcmp := m.Comp ecmp := mat2().Comp var qty float64 = 1.2 _, err := m.ExtractComp(qty, ecmp) assert.Err(t, err).Fatal() assert.Eq(t, m.Qty(), qty1) assert.Eq(t, m.Comp, mcmp) }
func TestExtractMass_Good(t *testing.T) { m := mat1() cmp := m.Comp var qty float64 = 4.9 e, err := m.ExtractMass(qty) assert.NoErr(t, err).Fatal() assert.Eq(t, m.Qty(), qty1-qty) assert.Eq(t, e.Qty(), qty) assert.Eq(t, m.Comp, cmp) assert.Eq(t, e.Comp, cmp) }
func TestExtractComp_Good(t *testing.T) { m := mat1() mcmp := m.Comp ecmp := mat2().Comp var qty float64 = 1.0 e, err := m.ExtractComp(qty, ecmp) assert.NoErr(t, err).Fatal() assert.Eq(t, m.Qty(), qty1-qty) assert.Eq(t, e.Qty(), qty) assert.Ne(t, m.Comp, mcmp) assert.Eq(t, e.Comp, ecmp) }
func TestClone(t *testing.T) { m := mat1() clone := m.Clone().(*Material) assert.Eq(t, m.Comp, clone.Comp) }
func TestUnits(t *testing.T) { assert.Eq(t, mat1().Units(), "kg") }
func TestType(t *testing.T) { assert.Eq(t, mat1().Type(), Type) }