mirror of
https://github.com/Crocmagnon/advent-of-code.git
synced 2024-12-22 13:51:55 +01:00
fix new day script
This commit is contained in:
parent
c67b57c949
commit
c554a5e463
3 changed files with 27 additions and 22 deletions
18
2023/lib_test.go
Normal file
18
2023/lib_test.go
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package _023
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func check(test testCase, fn solveFunc) func(t *testing.T) {
|
||||||
|
return func(t *testing.T) {
|
||||||
|
file, err := os.Open(test.filename)
|
||||||
|
require.NoError(t, err)
|
||||||
|
got, err := fn(file)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, test.want, got)
|
||||||
|
}
|
||||||
|
}
|
18
2023/new_day
18
2023/new_day
|
@ -7,19 +7,19 @@ if [[ $# -ne 2 ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
filename=day$1_$2
|
filename=day$1_$2
|
||||||
cp template.go $filename.go
|
cp template.go ${filename}.go
|
||||||
cp template_test.go $filename_test.go
|
cp template_test.go ${filename}_test.go
|
||||||
if [ "$(uname -s)" == "Linux" ]; then
|
if [ "$(uname -s)" == "Linux" ]; then
|
||||||
sed -e "s/Dxx/day$1/g" -i ./$filename.go
|
sed -e "s/Dxx/Day$1/g" -i ./${filename}.go
|
||||||
sed -e "s/Dxx/day$1/g" -i ./$filename_test.go
|
sed -e "s/Dxx/Day$1/g" -i ./${filename}_test.go
|
||||||
sed -e "s/dayxx/day$1/g" -i ./$filename_test.go
|
sed -e "s/dayxx/day$1/g" -i ./${filename}_test.go
|
||||||
else
|
else
|
||||||
sed -e "s/Dxx/day$1/g" -i "" ./$filename.go
|
sed -e "s/Dxx/Day$1/g" -i "" ./${filename}.go
|
||||||
sed -e "s/Dxx/day$1/g" -i "" ./$filename_test.go
|
sed -e "s/Dxx/Day$1/g" -i "" ./${filename}_test.go
|
||||||
sed -e "s/dayxx/day$1/g" -i "" ./$filename_test.go
|
sed -e "s/dayxx/day$1/g" -i "" ./${filename}_test.go
|
||||||
fi
|
fi
|
||||||
mkdir -p inputs
|
mkdir -p inputs
|
||||||
touch inputs/day$1
|
touch inputs/day$1
|
||||||
touch inputs/day$1_test1
|
touch inputs/day$1_test1
|
||||||
touch inputs/day$1_test2
|
touch inputs/day$1_test2
|
||||||
git add "inputs/day$1*" $filename
|
git add "inputs/day$1*" ${filename}*
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package _023
|
package _023
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,13 +23,3 @@ func TestDxxPart2(t *testing.T) {
|
||||||
t.Run(test.filename, check(test, DxxPart2))
|
t.Run(test.filename, check(test, DxxPart2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func check(test testCase, fn solveFunc) func(t *testing.T) {
|
|
||||||
return func(t *testing.T) {
|
|
||||||
file, err := os.Open(test.filename)
|
|
||||||
require.NoError(t, err)
|
|
||||||
got, err := fn(file)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, test.want, got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue