@Theory( nullsAccepted = false ) public void appendedDoubleWithPrecisionParsesAsItselfWithTolerance( final Double value, @TestedOn( ints = { 0, 1, 2, 3, 10, 16, 19, 20 } ) final int digits ) { final ByteBuffer buffer = ByteBuffer.allocate( 50 ); BufferFormatter.append( buffer, value, digits ); final String formatted = BufferFormatterTest.toString( buffer ); final double parsedValue = Double.parseDouble( formatted ); assertThat( ".append(" + value + "," + digits + ") -> [" + formatted + "] -> [" + parsedValue + "]", parsedValue, closeTo( value, tolerance( digits ) ) ); }
@Theory( nullsAccepted = false ) public void appendedDoubleWithPrecisionParsesAsItselfWithToleranceCB( final Double value, @TestedOn( ints = { 0, 1, 2, 3, 10, 16, 19, 20 } ) final int digits ) { final CharBuffer buffer = CharBuffer.allocate( 50 ); BufferFormatter.append( buffer, value, digits ); final String formatted = BufferFormatterTest.toString( buffer ); final double parsedValue = Double.parseDouble( formatted ); assertThat( ".append(" + value + "," + digits + ") -> [" + formatted + "] -> [" + parsedValue + "]", parsedValue, closeTo( value, tolerance( digits ) ) ); }
@Theory public void testNotExistChars(@TestedOn(ints = { 5, 50, 500 }) int count) { StringBuilder sb = new StringBuilder(); IntStream.range(0, count) .mapToObj(a -> (char) (Math.random() * 100 + 128)) .forEach(sb::append); String string = sb.toString(); Flowable.fromIterable(() -> notExistChars(string)) .test(0) .requestMore(count) .assertNever(c -> string.indexOf(c.charValue()) != -1); }
@Test public void getAnnotations() throws SecurityException, NoSuchMethodException { Method method = getClass().getMethod("foo", int.class); List<Annotation> annotations = ParameterSignature.signatures(method) .get(0).getAnnotations(); assertThat(annotations, CoreMatchers.<TestedOn>hasItem(isA(TestedOn.class))); }
@Test public void getAnnotations() throws SecurityException, NoSuchMethodException { Method method = ParameterSignatureTest.class.getMethod("foo", int.class); List<Annotation> annotations = ParameterSignature.signatures(method) .get(0).getAnnotations(); assertThat(annotations, CoreMatchers.<TestedOn>hasItem(isA(TestedOn.class))); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, @NonNull FontScale fontScale, @NonNull PrimaryTestImg image, @NonNull PrimaryTestStr title, @NonNull SecondaryTestStr subtitle) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, image, title, subtitle, BLUE); snap(subject, image + "_image", title + "_title", subtitle + "_subtitle"); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, @NonNull FontScale fontScale, @NonNull PrimaryTestStr title, @NonNull SecondaryTestStr subtitle, @TestedOn(ints = {0, 1, MAX_SUGGESTIONS}) int suggestions) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, title, subtitle, TODAY, suggestions); snap(subject, title + "_title", subtitle + "_subtitle", suggestions + "_suggestions"); }
@Theory public void testSetSubtitle(@TestedOn(ints = {TODAY, TOMORROW, 2}) int age) { setUp(WIDTH_DP_L, LayoutDirection.LOCALE, FontScale.DEFAULT, Theme.LIGHT, PrimaryTestStr.SHORT, SecondaryTestStr.SHORT, TODAY, MAX_SUGGESTIONS); String expected; switch (age) { case TODAY: expected = "Today"; break; case TOMORROW: expected = "Yesterday"; break; default: expected = String.valueOf(age); } String subtitle = subject.getSubtitle(age); assertThat(subtitle, containsString(expected)); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_XL, WIDTH_DP_L}) int widthDp, @NonNull FontScale fontScale, @NonNull PrimaryTestStr title, @NonNull SecondaryTestStr description, @NonNull PrimaryTestStr error, @TestedOnBool boolean saving) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, title, description, error, saving); snap(subject, title + "_title", description + "_description", error + "_error", saving ? "saving" : "unsaved"); }
@Theory public void testLayout(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, // @TestedOn(ints = {HEIGHT_DP_L, WIDTH_DP_S}) int heightDp, @NonNull FontScale fontScale, @NonNull PrimaryTestImg image, @NonNull PrimaryTestStr title, @NonNull SecondaryTestStr subtitle, @TestedOnBool boolean pronunciation) { // todo: pass height when layout is correct setUp(widthDp, 0, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, image, title, subtitle, pronunciation); snap(subject, image + "_image", title + "_title", subtitle + "_subtitle", pronunciation ? "pronunciation" : "no_pronunciation"); }
@Theory public void testOnScrollChanged(@TestedOn(ints = {-1, 0, 1}) int y) { setUpTypical(); // width and height must be > 0 for Bitmap.createBitmap() final int height = 100; ViewHelpers.setupView(subject).setExactHeightDp(height).layout(); subject.onScrollChanged(0, y, false); assertThat((int) subject.getTranslationY(), is(-Math.min(height, y))); assertThat((int) subject.image.getImage().getTranslationY(), is(y / 2)); }
public void foo(@TestedOn(ints = {1, 2, 3}) int x) { }
public void foo(@TestedOn(ints = {1}) int x) { }
@Theory public void everythingIsOne(@TestedOn(ints = {1}) int number) { assertThat(number, is(1)); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_XS, WIDTH_DP_S, WIDTH_DP_M, WIDTH_DP_XL}) int widthDp, @NonNull FontScale fontScale, @NonNull TertiaryTestStr text) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT); subject.setTextWithDrawables("^1 " + str(text) + " ^2", R.drawable.ic_mode_edit_white_24dp, R.drawable.cc_logo); snap(subject, text + "_text"); }
@Theory public void testLayoutDirection(@TestedOn(ints = {WIDTH_DP_XS, WIDTH_DP_M}) int widthDp, @NonNull LayoutDirection direction) { setUp(widthDp, direction, FontScale.DEFAULT, Theme.LIGHT); subject.setTextWithDrawables("Every good ^1 does ^2.", R.drawable.ic_mode_edit_white_24dp, R.drawable.cc_logo); snap(subject); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, @NonNull FontScale fontScale, @NonNull PrimaryTestStr text) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, text); snap(subject, text + "_text"); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, @NonNull FontScale fontScale, @NonNull PrimaryTestStr text) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, text); snap(textView, text + "_text"); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, @NonNull FontScale fontScale) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, IMAGE); snap(subject); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, @NonNull FontScale fontScale, @NonNull PrimaryTestImg image, @NonNull PrimaryTestStr title, @NonNull SecondaryTestStr subtitle) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, image, title, subtitle); snap(subject, image + "_image", title + "_title", subtitle + "_subtitle"); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_L, WIDTH_DP_M}) int widthDp, @NonNull FontScale fontScale, @NonNull SecondaryTestImg image, @NonNull PrimaryTestStr title) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT, image, title); snap(subject, image + "_image", title + "_title"); }
@Theory public void testTheme(@NonNull Theme theme, @TestedOn(ints = {BLUE, R.color.green50}) int circleColor) { setUp(WIDTH_DP_L, LayoutDirection.LOCALE, FontScale.DEFAULT, theme, PrimaryTestImg.NONNULL, PrimaryTestStr.SHORT, SecondaryTestStr.SHORT, circleColor); snap(subject, circleColor == BLUE ? "blue" : "green"); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_XL, WIDTH_DP_L}) int widthDp, @NonNull FontScale fontScale) { setUp(widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT); snap(subject); }
@Theory public void testWidth(@TestedOn(ints = {WIDTH_DP_XL, WIDTH_DP_L}) int widthDp, @NonNull FontScale fontScale) { for (DescriptionEditTutorialPage page : DescriptionEditTutorialPage.values()) { setUp(page, widthDp, LayoutDirection.LOCALE, fontScale, Theme.LIGHT); snap(subject, page.name()); } }