Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

チュートリアル Javaコーディング問題(TestRunner版) 作り込み編 #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contents/tutorial/coding-java-testrunner-finishing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
整数 `x` と `y` を引数で受け取り、足し算した値を戻り値として返す `add(int x, int y)` メソッドを実装してください。


## 例

``` java
add(2, 3) // 5
add(15, 8) // 23
add(65, 94) // 159
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 問題のポイント
次のような内容を問う問題です。

- 基本的な足し算ができること
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class App {
public static int add(int x, int y) {
return x + y;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class App {
public static int add(int x, int y) {
return -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Main {
public static void main(String[] args) {
int x = Integer.parseInt(args[0]);
int y = Integer.parseInt(args[1]);
System.out.print(App.add(x, y));
}
}
11 changes: 11 additions & 0 deletions contents/tutorial/coding-java-testrunner-finishing/test/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const codecheck = require("codecheck");

const language = process.env.CHALLENGE_LANGUAGE || "ja";
const appCommand = process.env.APP_COMMAND;

const settings = require("./settings.json");
settings.language = language;
const testcases = require("./basic_testcases.json");

const testRunner = codecheck.testRunner(settings, appCommand);
testRunner.runAll(testcases);
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"input": "in/public/01.in",
"output": "out/public/01.out",
"description": "[基本実装] 入力が 2 と 3 のとき、期待された出力結果が得られる"
},
{
"input": "in/public/02.in",
"output": "out/public/02.out",
"description": "[基本実装] 入力が 15 と 8 のとき、期待された出力結果が得られる"
},
{
"input": "in/public/03.in",
"output": "out/public/03.out",
"description": "[基本実装] 入力が 65 と 94 のとき、期待された出力結果が得られる"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2 3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15 8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
65 94
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
23
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
159
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
11 changes: 11 additions & 0 deletions contents/tutorial/coding-java-testrunner-finishing/test/secret.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const codecheck = require("codecheck");

const language = process.env.CHALLENGE_LANGUAGE || "ja";
const appCommand = process.env.APP_COMMAND;

const settings = require("./settings.json");
settings.language = language;
const testcases = require("./secret_testcases.json");

const testRunner = codecheck.testRunner(settings, appCommand);
testRunner.runAll(testcases);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"input": "in/secret/04.in",
"output": "out/secret/04.out",
"description": "[コーナーケース] x の値が最小のとき、期待された出力結果が得られる"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"input": {
"type": "arguments",
"source": "file"
},
"output": {
"type": "stdout",
"source": "file"
}
}
34 changes: 34 additions & 0 deletions contents/tutorial/coding-java-testrunner-finishing/track.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
type: coding
main: src/App.java
editable:
- src/App.java
readonly:
- src/Main.java
- test/*basic*
- test/in/public/*
- test/out/public/*
- test/settings.json
hide:
- test/*secret*
- test/in/secret/*
- test/out/secret/*
build: javac src/*.java
test: mocha --exit -R track-reporter
envConf:
imageName: java
variables:
APP_COMMAND: java -classpath src Main
solutions:
- src/App.java:solution/App.java
testcases:
open: 3
secret: 1
debug:
command: $c $*
input:
- "file:[[基本実装] 入力が 2 と 3 のとき、期待された出力結果が得られる]test/in/public/01.in"
- "file:[[基本実装] 入力が 15 と 8 のとき、期待された出力結果が得られる]test/in/public/02.in"
- "file:[[基本実装] 入力が 65 と 94 のとき、期待された出力結果が得られる]test/in/public/03.in"
evaluationPoint:
基本実装: 基本的なテストケースにおいて、正答が出力できる
コーナーケース: 境界値のテストケースにおいて、正答が出力できる