Skip to content

Commit 29225c5

Browse files
committed
add huge test in go
1 parent 1a1282d commit 29225c5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

py3/hard/median/REMARK

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
There is a file "generate_large.go" which generates ~150MB file for tests.
2+
The reason it's written in go is that it takes infinite RAM to do it in python

py3/hard/median/generate_large.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import "fmt"
4+
import "strings"
5+
import "encoding/json"
6+
import "io/ioutil"
7+
8+
type Test struct {
9+
Input string `json:"input"`
10+
Output string `json:"output"`
11+
}
12+
13+
func main() {
14+
var a strings.Builder
15+
a.Grow(1000 * 1000 * 10)
16+
for i := 0; i < 1000 * 1000 * 10; i++ {
17+
fmt.Fprintf(&a, "%d ", i)
18+
}
19+
as := a.String()
20+
var b strings.Builder
21+
b.Grow(20 * 1000 * 1000)
22+
fmt.Fprintf(&b, "%s\n%s", as, as)
23+
t := Test{Input: b.String(), Output: "4999999.5"}
24+
25+
file, _ := json.Marshal(t)
26+
err := ioutil.WriteFile("test/test_large_go", file, 0666)
27+
if err != nil {
28+
fmt.Println(err.Error())
29+
}
30+
}

0 commit comments

Comments
 (0)