Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
ens:dasi2014:juint [2014/04/03 08:08] admin Cordier Amelie () |
ens:dasi2014:juint [2014/04/03 09:54] admin Cordier Amelie () |
||
---|---|---|---|
Ligne 50: | Ligne 50: | ||
| | ||
public int sum(String s) { | public int sum(String s) { | ||
- | if (s=="" | + | if (s==" ") return 0; |
- | if (s.length ()==1 return ((int)(s.charAt(0))); | + | if (s.length ()==1) return ((int)(s.charAt(0))); |
return ((int)(s.charAt(0))) + sum(s.substring(1)); | return ((int)(s.charAt(0))) + sum(s.substring(1)); | ||
} | } | ||
| | ||
public String binarise(int x) { | public String binarise(int x) { | ||
- | if (x==0) return ""; | + | if (x==0) return " "; |
if (x%2==1) return " | if (x%2==1) return " | ||
return " | return " | ||
Ligne 69: | Ligne 69: | ||
public classBinStringTest extends TestCase { | public classBinStringTest extends TestCase { | ||
| | ||
+ | |||
+ | public BinStringTest(String name) { | ||
+ | super (name); | ||
+ | } | ||
+ | |||
+ | protected void setUp(){ | ||
+ | binString = new BinString(); | ||
+ | } | ||
+ | |||
+ | public void testSumFunction(){ | ||
+ | int expected = 0; | ||
+ | assertEquals(expected, | ||
+ | expected = 100; | ||
+ | assertEquals(expected, | ||
+ | expected = 265; | ||
+ | assertEquals(expected, | ||
+ | } | ||
+ | |||
+ | public void testBinariseFunction() { | ||
+ | String expected = " | ||
+ | assertEquals(expected, | ||
+ | expected = " | ||
+ | assertEquals(expected, | ||
+ | } | ||
+ | |||
+ | public void testTotalConversion() { | ||
+ | String expected = " | ||
+ | assertEquals(expected, | ||
+ | } | ||
+ | } | ||
</ | </ | ||