This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FizzBuzz { | |
public static String eval(int n) { | |
return ""+((n%3==0)?"fizz"+((n%5==0)?"buzz":""):(n%5==0)?"buzz":n); | |
} | |
} | |
public class FizzBuzzTest { | |
@Test | |
public void testFizzBuzz() { | |
for(int i=0; i < 1000000; i++) { | |
String value = FizzBuzz.eval(i); | |
if (i % 3 == 0 && i % 5 == 0) { | |
assertThat(value, is("fizzbuzz")); | |
} else if (i % 3 == 0) { | |
assertThat(value, is("fizz")); | |
} else if (i % 5 == 0) { | |
assertThat(value, is("buzz")); | |
} else { | |
assertThat(value, is(String.valueOf(i))); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public class FizzBuzzTest {
@test
public void testFizzBuzz() {
String value = " ";
for(int i=0; i < 1000000; i++) {
}
}