Skip to content

Instantly share code, notes, and snippets.

@kijuky
Created May 28, 2011 23:56
Show Gist options
  • Save kijuky/997354 to your computer and use it in GitHub Desktop.
Save kijuky/997354 to your computer and use it in GitHub Desktop.
Amountの等値比較テスト
@GrabResolver(name='jsciencerepos', root='http://maven.obiba.org/maven2/')
@Grab('org.jscience:jscience:4.3.1')
import org.jscience.physics.amount.Amount
q = Amount.valueOf("1.0 kW")
dt = Amount.valueOf("1.0 K")
cp = q.divide(dt)
//assert Amount.valueOf("1.0 kW/K") != cp // なんかおかしい
assert !Amount.valueOf("1.0 kW/K").equals(cp)
assert Amount.valueOf("1.0 kW/K").approximates(cp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment