private void runMultiplicationCase(XmlPullParser xpp) throws XmlPullParserException, IOException, UcumException { String id = xpp.getAttributeValue(null, "id"); String v1 = xpp.getAttributeValue(null, "v1"); String u1 = xpp.getAttributeValue(null, "u1"); String v2 = xpp.getAttributeValue(null, "v2"); String u2 = xpp.getAttributeValue(null, "u2"); String vRes = xpp.getAttributeValue(null, "vRes"); String uRes = xpp.getAttributeValue(null, "uRes"); Pair o1 = new Pair(new Decimal(v1), u1); Pair o2 = new Pair(new Decimal(v2), u2); Pair o3 = ucumSvc.multiply(o1, o2); debug("Multiplication Test "+id+": the value '"+v1+" "+u1+"' * '"+v2+" "+u2+"' ==> "+o3.getValue().toString()+" "+o3.getCode()); // if (!res.toPlainString().equals(outcome)) { - that assumes that we can get the precision right, which we can't if (o3.getValue().comparesTo(new Decimal(vRes)) != 0 || !o3.getCode().equals(uRes)) { errCount++; System.err.println("Test "+id+": The value '"+vRes+" "+uRes+"' was expected, but the result was "+o3.getValue().toString()+" "+o3.getCode()); } while (xpp.getEventType() != XmlPullParser.END_TAG) xpp.next(); xpp.next(); }
@Override public Pair getCanonicalForm(Pair value) throws UcumException { assert value != null : paramError("getCanonicalForm", "value", "must not be null"); assert checkStringParam(value.getCode()) : paramError("getCanonicalForm", "value.code", "must not be null or empty"); Term term = new ExpressionParser(model).parse(value.getCode()); Canonical c = new Converter(model, handlers).convert(term); if (value.getValue() == null) return new Pair(null, new ExpressionComposer().compose(c, false)); else return new Pair(value.getValue().multiply(c.getValue()), new ExpressionComposer().compose(c, false)); }
private void runMultiplicationCase(XmlPullParser xpp) throws XmlPullParserException, IOException, UcumException { String id = xpp.getAttributeValue(null, "id"); String v1 = xpp.getAttributeValue(null, "v1"); String u1 = xpp.getAttributeValue(null, "u1"); String v2 = xpp.getAttributeValue(null, "v2"); String u2 = xpp.getAttributeValue(null, "u2"); String vRes = xpp.getAttributeValue(null, "vRes"); String uRes = xpp.getAttributeValue(null, "uRes"); Pair o1 = new Pair(new Decimal(v1), u1); Pair o2 = new Pair(new Decimal(v2), u2); Pair o3 = ucumSvc.multiply(o1, o2); debug("Multiplication Test "+id+": the value '"+v1+" "+u1+"' * '"+v2+" "+u2+"' ==> "+o3.getValue().toString()+" "+o3.getCode()); // if (!res.toPlainString().equals(outcome)) { - that assumes that we can get the precision right, which we can't if (o3.getValue().comparesTo(new Decimal(vRes)) != 0 || !o3.getCode().equals(uRes)) { errCount++; System.err.println("Test "+id+": The value '"+vRes+" "+uRes+"' was expected, but the result was "+o3.getValue().toString()+" "+o3.getCode()); } while (xpp.getEventType() != XmlPullParser.END_TAG) xpp.next(); xpp.next(); }
@Override public Pair getCanonicalForm(Pair value) throws UcumException { assert value != null : paramError("getCanonicalForm", "value", "must not be null"); assert checkStringParam(value.getCode()) : paramError("getCanonicalForm", "value.code", "must not be null or empty"); Term term = new ExpressionParser(model).parse(value.getCode()); Canonical c = new Converter(model, handlers).convert(term); if (value.getValue() == null) return new Pair(null, new ExpressionComposer().compose(c, false)); else return new Pair(value.getValue().multiply(c.getValue()), new ExpressionComposer().compose(c, false)); }