Skip to content

Commit

Permalink
Merge pull request #13 from chermehdi/bugfix/12-wrong-case-names
Browse files Browse the repository at this point in the history
Fix wrong io names. gofmt some files
  • Loading branch information
chermehdi authored Feb 22, 2020
2 parents bde0eb8 + d7c1381 commit f36a8ed
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions commands/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func AddNewCaseInput(inputLines []string,
if err != nil {
return metaData, err
}
inputFile := config.NewIoFile(inputFileName, path.Join("inputs", inputFileName), true)
inputFile := config.NewIoFile(caseName, path.Join("inputs", inputFileName), true)
metaData.Inputs = append(metaData.Inputs, inputFile)

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

return metaData, nil
Expand Down Expand Up @@ -133,10 +133,10 @@ func CustomCaseAction(context *cli.Context) error {
}

// Command to add costum test cases to the current task.
// Running this command will ask the user to provide their input and output, then
// Running this command will ask the user to provide their input and output, then
// saves the new test case data into appropriate files and add their meta data into
// the current task egor meta data.
// The user can add a flag --no-output to specify that this test case have no output
// The user can add a flag --no-output to specify that this test case have no output
// associated with it. The user will not be asked to provide output in this case.
var CaseCommand = cli.Command{
Name: "case",
Expand Down
54 changes: 27 additions & 27 deletions commands/case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,38 @@ import (
"github.com/chermehdi/egor/config"
"github.com/stretchr/testify/assert"
"os"
"path"
"testing"
)


func createDummyMetaData() (config.EgorMeta) {
meteData := config.EgorMeta {
TaskName: "Dummy Task",
TaskLang: "cpp",
Inputs: []config.IoFile {
config.IoFile {
Name: "test-0",
Path: "inputs/test-0.in",
Custom: false,
},
config.IoFile {
Name: "test-1",
Path: "inputs/test-1.in",
Custom: true,
},
},
Outputs: []config.IoFile {
config.IoFile {
Name: "test-0",
Path: "outputs/test-0.ans",
Custom: false,
func createDummyMetaData() config.EgorMeta {
meteData := config.EgorMeta{
TaskName: "Dummy Task",
TaskLang: "cpp",
Inputs: []config.IoFile{
config.IoFile{
Name: "test-0",
Path: "inputs/test-0.in",
Custom: false,
},
config.IoFile{
Name: "test-1",
Path: "inputs/test-1.in",
Custom: true,
},
},
Outputs: []config.IoFile{
config.IoFile{
Name: "test-0",
Path: "outputs/test-0.ans",
Custom: false,
},
},
}

return meteData
}


func TestAddNewCaseInput(t *testing.T) {
meteData := createDummyMetaData()

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

assert.Equal(t, err, nil)
assert.Equal(t, len(meteData.Inputs), 3)
assert.Equal(t, meteData.Inputs[2].Name, caseName + ".in")
assert.Equal(t, meteData.Inputs[2].Name, caseName)
assert.Equal(t, meteData.Inputs[2].Path, path.Join("inputs", caseName+".in"))
assert.Equal(t, meteData.Inputs[2].Custom, true)

}

}

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

assert.Equal(t, err, nil)
assert.Equal(t, len(meteData.Outputs), 2)
assert.Equal(t, meteData.Outputs[1].Name, caseName + ".ans")
assert.Equal(t, meteData.Outputs[1].Name, caseName)
assert.Equal(t, meteData.Outputs[1].Path, path.Join("outputs", caseName+".ans"))
assert.Equal(t, meteData.Outputs[1].Custom, true)

}
20 changes: 10 additions & 10 deletions commands/showcases.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ import (
)

type TestCaseIO struct {
Id int
Name string
InputPath string
Id int
Name string
InputPath string
OutputPath string
Custom bool
Custom bool
}

// parse input and output from egor meta to TestCase
func GetTestCases(egorMeta config.EgorMeta) []*TestCaseIO {
testCasesMap := make(map[string]*TestCaseIO)
testCases := make([]*TestCaseIO, 0)
for _, input := range egorMeta.Inputs {
testCase := &TestCaseIO {
Id : input.GetId(),
Name : input.Name,
InputPath : input.Path,
testCase := &TestCaseIO{
Id: input.GetId(),
Name: input.Name,
InputPath: input.Path,
OutputPath: "",
Custom: input.Custom,
Custom: input.Custom,
}
testCasesMap[input.Name] = testCase
testCases = append(testCases, testCase)
Expand Down Expand Up @@ -89,7 +89,7 @@ func ShowCasesAction(context *cli.Context) error {

color.Green("Listing %d testcase(s)...", metaData.CountTestCases())
color.Green("")

PrintTestCases(metaData)

return nil
Expand Down
34 changes: 17 additions & 17 deletions commands/showcases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import (
"testing"
)

func createSimpleDummyMetaData() config.EgorMeta{
meteData := config.EgorMeta {
TaskName: "Dummy Task",
TaskLang: "cpp",
Inputs: []config.IoFile {
config.IoFile {
Name: "test-0",
Path: "inputs/test-0.in",
Custom: true,
},
},
Outputs: []config.IoFile {
config.IoFile {
Name: "test-0",
Path: "outputs/test-0.ans",
Custom: true,
func createSimpleDummyMetaData() config.EgorMeta {
meteData := config.EgorMeta{
TaskName: "Dummy Task",
TaskLang: "cpp",
Inputs: []config.IoFile{
config.IoFile{
Name: "test-0",
Path: "inputs/test-0.in",
Custom: true,
},
},
Outputs: []config.IoFile{
config.IoFile{
Name: "test-0",
Path: "outputs/test-0.ans",
Custom: true,
},
},
}
Expand All @@ -42,4 +42,4 @@ func TestGetTestCases(t *testing.T) {
assert.Equal(t, testCases[0].InputPath, inputs[0].Path)
assert.Equal(t, testCases[0].OutputPath, outputs[0].Path)
assert.Equal(t, testCases[0].Custom, inputs[0].Custom)
}
}

0 comments on commit f36a8ed

Please sign in to comment.