use of org.odk.collect.android.formentry.questions.QuestionDetails in project collect by opendatakit.
the class DecimalWidgetTest method integerValueShouldDisplayNoDecimalPoint.
@Test
public // Fails when double is turned to string with toString or String.format(Locale.US, "%f", d))
void integerValueShouldDisplayNoDecimalPoint() {
Double integerDouble = 0.;
String integerString = "0";
when(formEntryPrompt.getAnswerValue()).thenReturn(answerData);
when(answerData.getValue()).thenReturn(integerDouble);
DecimalWidget decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(integerString)));
decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(integerString)));
}
use of org.odk.collect.android.formentry.questions.QuestionDetails in project collect by opendatakit.
the class DecimalWidgetTest method fifteenDigitNegativeValueShouldDisplayAllDigits.
@Test
public // https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#toString(double)
void fifteenDigitNegativeValueShouldDisplayAllDigits() {
Double fifteenDigitNegativeDouble = -99999999999999.;
String fifteenDigitNegativeString = "-99999999999999";
assertSame(15, fifteenDigitNegativeString.length());
when(formEntryPrompt.getAnswerValue()).thenReturn(answerData);
when(answerData.getValue()).thenReturn(fifteenDigitNegativeDouble);
DecimalWidget decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(fifteenDigitNegativeString)));
decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(fifteenDigitNegativeString)));
}
use of org.odk.collect.android.formentry.questions.QuestionDetails in project collect by opendatakit.
the class DecimalWidgetTest method negativeIntegerShouldDisplayNegativeWithNoDecimalPoint.
@Test
public // Fails when double is turned to string with toString or String.format(Locale.US, "%f", d)
void negativeIntegerShouldDisplayNegativeWithNoDecimalPoint() {
Double negativeIntegerDouble = -999.;
String negativeIntegerString = "-999";
when(formEntryPrompt.getAnswerValue()).thenReturn(answerData);
when(answerData.getValue()).thenReturn(negativeIntegerDouble);
DecimalWidget decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(negativeIntegerString)));
decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(negativeIntegerString)));
}
use of org.odk.collect.android.formentry.questions.QuestionDetails in project collect by opendatakit.
the class ExDecimalWidgetTest method digitsAboveLimitOfFifteenShouldBeTruncatedFromRight.
@Test
public // This should never be possible because the EditText has a limit on it
void digitsAboveLimitOfFifteenShouldBeTruncatedFromRight() {
Double eighteenDigitDouble = 9999999999999994.;
String fifteenDigitString = "999999999999994";
assertSame(15, fifteenDigitString.length());
when(formEntryPrompt.getAnswerValue()).thenReturn(answerData);
when(answerData.getValue()).thenReturn(eighteenDigitDouble);
ExDecimalWidget exDecimalWidget = new ExDecimalWidget(activity, new QuestionDetails(formEntryPrompt), new FakeWaitingForDataRegistry(), stringRequester);
assertThat(exDecimalWidget.getAnswerText(), is(equalTo(fifteenDigitString)));
exDecimalWidget = new ExDecimalWidget(activity, new QuestionDetails(formEntryPrompt), new FakeWaitingForDataRegistry(), stringRequester);
assertThat(exDecimalWidget.getAnswerText(), is(equalTo(fifteenDigitString)));
}
use of org.odk.collect.android.formentry.questions.QuestionDetails in project collect by opendatakit.
the class DecimalWidgetTest method fifteenDigitDecimalValueShouldDisplayAllDigits.
@Test
public // precision for %f is 6
void fifteenDigitDecimalValueShouldDisplayAllDigits() {
Double fifteenDigitDecimalDouble = 0.9999999999999;
String fifteenDigitDecimalString = "0.9999999999999";
assertSame(15, fifteenDigitDecimalString.length());
when(formEntryPrompt.getAnswerValue()).thenReturn(answerData);
when(answerData.getValue()).thenReturn(fifteenDigitDecimalDouble);
DecimalWidget decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(fifteenDigitDecimalString)));
decimalWidget = new DecimalWidget(activity, new QuestionDetails(formEntryPrompt));
assertThat(decimalWidget.getAnswerText(), is(equalTo(fifteenDigitDecimalString)));
}
Aggregations