DisplayFormat { public static String shortTrend(final RawDisplayData raw) { String minutes = "--"; if (raw.datetime > 0) { minutes = shortTimeSince(raw.datetime); } if (minutes.length() + raw.sDelta.length() + deltaSymbol().length() + 1 <= MAX_FIELD_LEN_SHORT) { return minutes + " " + deltaSymbol() + raw.sDelta; } String delta = (new SmallestDoubleString(raw.sDelta)).minimise(MAX_FIELD_LEN_SHORT -1); if (minutes.length() + delta.length() + deltaSymbol().length() + 1 <= MAX_FIELD_LEN_SHORT) { return minutes + " " + deltaSymbol() + delta; } String shortDelta = (new SmallestDoubleString(raw.sDelta)).minimise(MAX_FIELD_LEN_SHORT -(1+minutes.length())); return minutes + " " + shortDelta; }  static String deltaSymbol(); static String verticalSeparatorSymbol(); static String basalRateSymbol(); static String shortTimeSince(final long refTime); static String shortTrend(final RawDisplayData raw); static String longGlucoseLine(final RawDisplayData raw); static String longDetailsLine(final RawDisplayData raw); static Pair<String, String> detailedIob(RawDisplayData raw); static Pair<String, String> detailedCob(final RawDisplayData raw); static final int MAX_FIELD_LEN_LONG; static final int MAX_FIELD_LEN_SHORT; static final int MIN_FIELD_LEN_COB; static final int MIN_FIELD_LEN_IOB; }
@Test public void shortTrendTest() { RawDisplayData raw = new RawDisplayData(); assertThat(DisplayFormat.shortTrend(raw), is("-- Δ--")); raw.datetime = backInTime(0, 0, 2, 0); assertThat(DisplayFormat.shortTrend(raw), is("2' Δ--")); AAPSMocker.setMockedUnicodeComplicationsOn(true); assertThat(DisplayFormat.shortTrend(rawDelta(2, "1.2")), is("2' Δ1.2")); assertThat(DisplayFormat.shortTrend(rawDelta(11,"1.2")), is("11' 1.2")); assertThat(DisplayFormat.shortTrend(rawDelta(12,"0.7")), is("12' Δ.7")); assertThat(DisplayFormat.shortTrend(rawDelta(10,"1.0")), is("10' Δ1")); assertThat(DisplayFormat.shortTrend(rawDelta(14,"-5.0")), is("14' Δ-5")); assertThat(DisplayFormat.shortTrend(rawDelta(13,"-5.1")), is("13' -5")); assertThat(DisplayFormat.shortTrend(rawDelta(15,"0.87")), is("15' .87")); assertThat(DisplayFormat.shortTrend(rawDelta(10,"-1.78")), is("10' -2")); assertThat(DisplayFormat.shortTrend(rawDelta(3, "2.549")), is("3' 2.55")); assertThat(DisplayFormat.shortTrend(rawDelta(1, "-1.563")), is("1' -1.6")); assertThat(DisplayFormat.shortTrend(rawDelta(2, "1,2")), is("2' Δ1,2")); assertThat(DisplayFormat.shortTrend(rawDelta(15,"0,87")), is("15' ,87")); assertThat(DisplayFormat.shortTrend(rawDelta(3, "+2,549")), is("3' 2,55")); assertThat(DisplayFormat.shortTrend(rawDelta(1, "-1,563")), is("1' -1,6")); AAPSMocker.setMockedUnicodeComplicationsOn(false); assertThat(DisplayFormat.shortTrend(rawDelta(2, "1.2")), is("2' 1.2")); assertThat(DisplayFormat.shortTrend(rawDelta(12,"0.7")), is("12' 0.7")); assertThat(DisplayFormat.shortTrend(rawDelta(10,"1.0")), is("10' 1.0")); assertThat(DisplayFormat.shortTrend(rawDelta(14,"-5.0")), is("14' -5")); }