Skip to content

Commit d7c1381

Browse files
committed
Fix wrong io names. gofmt some files
1 parent bde0eb8 commit d7c1381

File tree

4 files changed

+58
-58
lines changed

4 files changed

+58
-58
lines changed

commands/case.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func AddNewCaseInput(inputLines []string,
5454
if err != nil {
5555
return metaData, err
5656
}
57-
inputFile := config.NewIoFile(inputFileName, path.Join("inputs", inputFileName), true)
57+
inputFile := config.NewIoFile(caseName, path.Join("inputs", inputFileName), true)
5858
metaData.Inputs = append(metaData.Inputs, inputFile)
5959

6060
return metaData, nil
@@ -70,7 +70,7 @@ func AddNewCaseOutput(outputLines []string,
7070
if err != nil {
7171
return metaData, err
7272
}
73-
outputFile := config.NewIoFile(outputFileName, path.Join("outputs", outputFileName), true)
73+
outputFile := config.NewIoFile(caseName, path.Join("outputs", outputFileName), true)
7474
metaData.Outputs = append(metaData.Outputs, outputFile)
7575

7676
return metaData, nil
@@ -133,10 +133,10 @@ func CustomCaseAction(context *cli.Context) error {
133133
}
134134

135135
// Command to add costum test cases to the current task.
136-
// Running this command will ask the user to provide their input and output, then
136+
// Running this command will ask the user to provide their input and output, then
137137
// saves the new test case data into appropriate files and add their meta data into
138138
// the current task egor meta data.
139-
// The user can add a flag --no-output to specify that this test case have no output
139+
// The user can add a flag --no-output to specify that this test case have no output
140140
// associated with it. The user will not be asked to provide output in this case.
141141
var CaseCommand = cli.Command{
142142
Name: "case",

commands/case_test.go

+27-27
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,38 @@ import (
44
"github.com/chermehdi/egor/config"
55
"github.com/stretchr/testify/assert"
66
"os"
7+
"path"
78
"testing"
89
)
910

10-
11-
func createDummyMetaData() (config.EgorMeta) {
12-
meteData := config.EgorMeta {
13-
TaskName: "Dummy Task",
14-
TaskLang: "cpp",
15-
Inputs: []config.IoFile {
16-
config.IoFile {
17-
Name: "test-0",
18-
Path: "inputs/test-0.in",
19-
Custom: false,
20-
},
21-
config.IoFile {
22-
Name: "test-1",
23-
Path: "inputs/test-1.in",
24-
Custom: true,
25-
},
26-
},
27-
Outputs: []config.IoFile {
28-
config.IoFile {
29-
Name: "test-0",
30-
Path: "outputs/test-0.ans",
31-
Custom: false,
11+
func createDummyMetaData() config.EgorMeta {
12+
meteData := config.EgorMeta{
13+
TaskName: "Dummy Task",
14+
TaskLang: "cpp",
15+
Inputs: []config.IoFile{
16+
config.IoFile{
17+
Name: "test-0",
18+
Path: "inputs/test-0.in",
19+
Custom: false,
20+
},
21+
config.IoFile{
22+
Name: "test-1",
23+
Path: "inputs/test-1.in",
24+
Custom: true,
25+
},
26+
},
27+
Outputs: []config.IoFile{
28+
config.IoFile{
29+
Name: "test-0",
30+
Path: "outputs/test-0.ans",
31+
Custom: false,
3232
},
3333
},
3434
}
3535

3636
return meteData
3737
}
3838

39-
4039
func TestAddNewCaseInput(t *testing.T) {
4140
meteData := createDummyMetaData()
4241

@@ -50,11 +49,11 @@ func TestAddNewCaseInput(t *testing.T) {
5049

5150
assert.Equal(t, err, nil)
5251
assert.Equal(t, len(meteData.Inputs), 3)
53-
assert.Equal(t, meteData.Inputs[2].Name, caseName + ".in")
52+
assert.Equal(t, meteData.Inputs[2].Name, caseName)
53+
assert.Equal(t, meteData.Inputs[2].Path, path.Join("inputs", caseName+".in"))
5454
assert.Equal(t, meteData.Inputs[2].Custom, true)
55-
56-
}
5755

56+
}
5857

5958
func TestAddNewCaseOutput(t *testing.T) {
6059
meteData := createDummyMetaData()
@@ -69,7 +68,8 @@ func TestAddNewCaseOutput(t *testing.T) {
6968

7069
assert.Equal(t, err, nil)
7170
assert.Equal(t, len(meteData.Outputs), 2)
72-
assert.Equal(t, meteData.Outputs[1].Name, caseName + ".ans")
71+
assert.Equal(t, meteData.Outputs[1].Name, caseName)
72+
assert.Equal(t, meteData.Outputs[1].Path, path.Join("outputs", caseName+".ans"))
7373
assert.Equal(t, meteData.Outputs[1].Custom, true)
7474

7575
}

commands/showcases.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ import (
1010
)
1111

1212
type TestCaseIO struct {
13-
Id int
14-
Name string
15-
InputPath string
13+
Id int
14+
Name string
15+
InputPath string
1616
OutputPath string
17-
Custom bool
17+
Custom bool
1818
}
1919

2020
// parse input and output from egor meta to TestCase
2121
func GetTestCases(egorMeta config.EgorMeta) []*TestCaseIO {
2222
testCasesMap := make(map[string]*TestCaseIO)
2323
testCases := make([]*TestCaseIO, 0)
2424
for _, input := range egorMeta.Inputs {
25-
testCase := &TestCaseIO {
26-
Id : input.GetId(),
27-
Name : input.Name,
28-
InputPath : input.Path,
25+
testCase := &TestCaseIO{
26+
Id: input.GetId(),
27+
Name: input.Name,
28+
InputPath: input.Path,
2929
OutputPath: "",
30-
Custom: input.Custom,
30+
Custom: input.Custom,
3131
}
3232
testCasesMap[input.Name] = testCase
3333
testCases = append(testCases, testCase)
@@ -89,7 +89,7 @@ func ShowCasesAction(context *cli.Context) error {
8989

9090
color.Green("Listing %d testcase(s)...", metaData.CountTestCases())
9191
color.Green("")
92-
92+
9393
PrintTestCases(metaData)
9494

9595
return nil

commands/showcases_test.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ import (
66
"testing"
77
)
88

9-
func createSimpleDummyMetaData() config.EgorMeta{
10-
meteData := config.EgorMeta {
11-
TaskName: "Dummy Task",
12-
TaskLang: "cpp",
13-
Inputs: []config.IoFile {
14-
config.IoFile {
15-
Name: "test-0",
16-
Path: "inputs/test-0.in",
17-
Custom: true,
18-
},
19-
},
20-
Outputs: []config.IoFile {
21-
config.IoFile {
22-
Name: "test-0",
23-
Path: "outputs/test-0.ans",
24-
Custom: true,
9+
func createSimpleDummyMetaData() config.EgorMeta {
10+
meteData := config.EgorMeta{
11+
TaskName: "Dummy Task",
12+
TaskLang: "cpp",
13+
Inputs: []config.IoFile{
14+
config.IoFile{
15+
Name: "test-0",
16+
Path: "inputs/test-0.in",
17+
Custom: true,
18+
},
19+
},
20+
Outputs: []config.IoFile{
21+
config.IoFile{
22+
Name: "test-0",
23+
Path: "outputs/test-0.ans",
24+
Custom: true,
2525
},
2626
},
2727
}
@@ -42,4 +42,4 @@ func TestGetTestCases(t *testing.T) {
4242
assert.Equal(t, testCases[0].InputPath, inputs[0].Path)
4343
assert.Equal(t, testCases[0].OutputPath, outputs[0].Path)
4444
assert.Equal(t, testCases[0].Custom, inputs[0].Custom)
45-
}
45+
}

0 commit comments

Comments
 (0)