私のプログラムは次のとおりです。
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
public class MangoDemo
{
public static void main(String[ ] args) throws FileNotFoundException
{
output();
}
public static void output() throws FileNotFoundException{
char[] lineChar = null;
Scanner scanner = new Scanner(new File("src/input.txt"));
while(scanner.hasNextLine()){
String line = scanner.nextLine();
//System.out.println(line);
lineChar = line.toCharArray();
sortStringBubble (lineChar);
int n = lineChar.length-1;
System.out.print(lineChar[n--]);
for (; n >=0; n-- ) {
if(lineChar[n] != ',') {
System.out.print(",");
System.out.print(lineChar[n]);
}
}
System.out.println();
}//end oof while loop
}
public static void sortStringBubble( char x [ ] )
{
int j;
boolean flag = true; // will determine when the sort is finished
char temp;
while ( flag )
{
flag = false;
for ( j = 0; j < x.length - 1; j++ )
{
if ( Character.toString(x[j]).compareToIgnoreCase( Character.toString(x[j+1]) ) > 0 )
{ // sorting in ascending order
temp = x[j];
x [j] = x [j+1]; // swapping here
x [j+1] = temp;
flag = true;
}
}
}
}
}
私はテストケースを作成しようとしました、そしてここにそれがあります:
import static org.junit.Assert.*;
import org.junit.Test;
public class MangoDemoTest {
@Test
public void testoutput() {
MangoDemo m = new MangoDemo();
char[] a = {'a','b','c'};
assertEquals("Result: ","c,b,a",m.output());
}
@Test
public void testSortStringBubble() {
fail("Not yet implemented");
}
}
私はこれに全くの初心者です。私もエラーが発生しています。出力関数にパラメーターを指定せずに出力をテストできる方法はありませんか?誰か助けてもらえますか?
ありがとう