text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
func TestAPIRequestParameters_WithFilter_AddsFilter(t *testing.T) {
f := APIRequestFiltering{
Property: "testproperty1",
Operator: EQOperator,
Value: []string{"testvalue1"},
}
params := APIRequestParameters{}
params.WithFilter(f)
assert.Len(t, params.Filtering, 1)
assert.Equal(t, f, params.Filtering[0])
} | explode_data.jsonl/44623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
7082,
1900,
9706,
62,
2354,
5632,
21346,
82,
5632,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
5333,
1900,
5632,
287,
515,
197,
197,
3052,
25,
330,
1944,
3699,
16,
756,
197,
197,
18461,
25,
38994,
18461,
345,
197,
47399,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMailForwardEncoding(t *testing.T) {
fwd := MailForward{
Name: "foobar@example.org",
TargetAddress: "info@example.org",
}
fixtArgs := `<mailForward xsi:type="ns1:MailForward">
<name xsi:type="xsd:string">foobar@example.org</name>
<targetAddress xsi:type="xsd:string">info@example.org</targetAddress>
</mailForward>`
assert.Equal(t, fixtArgs, fwd.EncodeArgs("mailForward"))
prm := gotransip.TestParamsContainer{}
fwd.EncodeParams(&prm, "")
assert.Equal(t, "00[name]=foobar@example.org&270[targetAddress]=info@example.org", prm.Prm)
} | explode_data.jsonl/35227 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
16702,
25925,
14690,
1155,
353,
8840,
836,
8,
341,
1166,
6377,
1669,
14874,
25925,
515,
197,
21297,
25,
688,
330,
50267,
35487,
2659,
756,
197,
197,
6397,
4286,
25,
330,
2733,
35487,
2659,
756,
197,
630,
1166,
941,
83,
411... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_downloadReleaseAssetCRDs(t *testing.T) {
renderer := buildTestRenderer()
asset := ReleaseAssetFileDefinition{
Owner: "kubernetes-sigs",
Repo: "cluster-api",
Version: "v0.3.22",
Files: []string{"cluster-api-components.yaml"},
Provider: "aws",
}
crds, err := renderer.downloadReleaseAssetCRDs(context.Background(), asset)
require.Nil(t, err, err)
require.Len(t, crds, 11)
} | explode_data.jsonl/3688 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
35939,
16077,
16604,
8973,
66950,
1155,
353,
8840,
836,
8,
341,
83509,
1669,
1936,
2271,
11541,
741,
197,
9852,
1669,
17381,
16604,
1703,
10398,
515,
197,
197,
13801,
25,
262,
330,
74,
29827,
1331,
14462,
756,
197,
197,
2524... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWalkSkipDirOnFile(t *testing.T) {
td, err := ioutil.TempDir("", "walktest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(td)
if err := os.MkdirAll(filepath.Join(td, "dir"), 0755); err != nil {
t.Fatal(err)
}
touch(t, filepath.Join(td, "dir/foo1"))
touch(t, filepath.Join(td, "dir/foo2"))
sawFoo2 := false
walker := func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(path, "foo2") {
sawFoo2 = true
}
if strings.HasSuffix(path, "foo1") {
return filepath.SkipDir
}
return nil
}
err = filepath.Walk(td, walker)
if err != nil {
t.Fatal(err)
}
if sawFoo2 {
t.Errorf("SkipDir on file foo1 did not block processing of foo2")
}
err = filepath.Walk(filepath.Join(td, "dir"), walker)
if err != nil {
t.Fatal(err)
}
if sawFoo2 {
t.Errorf("SkipDir on file foo1 did not block processing of foo2")
}
} | explode_data.jsonl/1660 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 388
} | [
2830,
3393,
48849,
35134,
6184,
1925,
1703,
1155,
353,
8840,
836,
8,
341,
76373,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
19059,
1944,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
16867,
2643,
84427,
61... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInvalidUrl(t *testing.T) {
//
// Missing protocol scheme - url.Parse should fail
//
url := "://foobar.com"
_, err := Get(url, nil, nil, nil)
assert.NotEqual(t, nil, err)
//
// Unsupported protocol scheme - HttpClient.Do should fail
//
url = "foo://bar.com"
_, err = Get(url, nil, nil, nil)
assert.NotEqual(t, nil, err)
} | explode_data.jsonl/14806 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
7928,
2864,
1155,
353,
8840,
836,
8,
341,
197,
2289,
197,
322,
220,
35264,
11507,
12859,
481,
2515,
8937,
1265,
3690,
198,
197,
6320,
19320,
1669,
330,
1110,
50267,
905,
698,
197,
6878,
1848,
1669,
2126,
6522,
11,
2092,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAkimaSpline(t *testing.T) {
t.Parallel()
const (
derivAbsTol = 1e-8
derivRelTol = 1e-7
h = 1e-8
nPts = 100
tol = 1e-14
)
for i, test := range []struct {
xs []float64
f func(float64) float64
}{
{
xs: []float64{-5, -3, -2, -1.5, -1, 0.5, 1.5, 2.5, 3},
f: func(x float64) float64 { return x * x },
},
{
xs: []float64{-5, -3, -2, -1.5, -1, 0.5, 1.5, 2.5, 3},
f: func(x float64) float64 { return math.Pow(x, 3.) - x*x + 2 },
},
{
xs: []float64{-5, -3, -2, -1.5, -1, 0.5, 1.5, 2.5, 3},
f: func(x float64) float64 { return -10 * x },
},
{
xs: []float64{-5, -3, -2, -1.5, -1, 0.5, 1.5, 2.5, 3},
f: math.Sin,
},
{
xs: []float64{0, 1},
f: math.Exp,
},
{
xs: []float64{-1, 0.5},
f: math.Cos,
},
} {
var as AkimaSpline
n := len(test.xs)
m := n - 1
x0 := test.xs[0]
x1 := test.xs[m]
ys := applyFunc(test.xs, test.f)
err := as.Fit(test.xs, ys)
if err != nil {
t.Errorf("Error when fitting AkimaSpline in test case %d: %v", i, err)
}
for j := 0; j < n; j++ {
x := test.xs[j]
got := as.Predict(x)
want := test.f(x)
if math.Abs(got-want) > tol {
t.Errorf("Mismatch in interpolated value at x == %g for test case %d: got %v, want %g", x, i, got, want)
}
if j < m {
dx := (test.xs[j+1] - x) / nPts
for k := 1; k < nPts; k++ {
xk := x + float64(k)*dx
got = as.PredictDerivative(xk)
want = discrDerivPredict(&as, x0, x1, xk, h)
if math.Abs(got-want) > derivRelTol*math.Abs(want)+derivAbsTol {
t.Errorf("Mismatch in interpolated derivative at x == %g for test case %d: got %v, want %g", x, i, got, want)
}
}
}
}
if n == 2 {
got := as.cubic.coeffs.At(0, 1)
want := (ys[1] - ys[0]) / (test.xs[1] - test.xs[0])
if math.Abs(got-want) > tol {
t.Errorf("Mismatch in approximated slope for length-2 test case %d: got %v, want %g", i, got, want)
}
for j := 2; i < 4; j++ {
got := as.cubic.coeffs.At(0, j)
if got != 0 {
t.Errorf("Non-zero order-%d coefficient for length-2 test case %d: got %v", j, i, got)
}
}
}
}
} | explode_data.jsonl/44082 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1186
} | [
2830,
3393,
55802,
7523,
50,
31439,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
4777,
2399,
197,
197,
82495,
27778,
51,
337,
284,
220,
16,
68,
12,
23,
198,
197,
197,
82495,
6740,
51,
337,
284,
220,
16,
68,
12,
22,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWrapNil(t *testing.T) {
got := Wrap(nil, "no error")
if got != nil {
t.Errorf("Wrap(nil, \"no error\"): got %#v, expected nil", got)
}
} | explode_data.jsonl/60771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
26787,
19064,
1155,
353,
8840,
836,
8,
341,
3174,
354,
1669,
42187,
27907,
11,
330,
2152,
1465,
1138,
743,
2684,
961,
2092,
341,
197,
3244,
13080,
445,
26787,
27907,
11,
7245,
2152,
1465,
59,
37051,
2684,
52406,
85,
11,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestHTTPHandlerPutUnrecognizedLevel(t *testing.T) {
lvl, _ := newHandler()
code, body := makeRequest(t, "PUT", lvl, strings.NewReader(`{"level":"unrecognized-level"}`))
assertCodeBadRequest(t, code)
assertJSONError(t, body)
} | explode_data.jsonl/7603 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
9230,
3050,
19103,
1806,
46067,
4449,
1155,
353,
8840,
836,
8,
341,
8810,
14536,
11,
716,
1669,
501,
3050,
741,
43343,
11,
2487,
1669,
1281,
1900,
1155,
11,
330,
6221,
497,
46129,
11,
9069,
68587,
5809,
4913,
3294,
3252,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestStrong(t *testing.T) {
reqs := Strong
p, e := NewPassword(&reqs)
if e != nil {
t.Error(e)
}
if ok, msg := reqs.Validate(p); !ok {
t.Error(msg)
}
} | explode_data.jsonl/7149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
47586,
1155,
353,
8840,
836,
8,
341,
24395,
82,
1669,
26099,
198,
3223,
11,
384,
1669,
1532,
4876,
2099,
2958,
82,
340,
743,
384,
961,
2092,
341,
197,
3244,
6141,
2026,
340,
197,
532,
743,
5394,
11,
3750,
1669,
4232,
82,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 3 |
func TestRendererService(t *testing.T) {
tc := testutil.EndToEndTest(t)
service := cloudrunci.NewService("render", tc.ProjectID)
if err := service.Deploy(); err != nil {
t.Fatalf("service.Deploy %q: %v", service.Name, err)
}
defer service.Clean()
for _, test := range tests {
req, err := service.NewRequest("POST", "/")
if err != nil {
t.Fatalf("service.NewRequest: %q", err)
}
req.Body = ioutil.NopCloser(strings.NewReader(test.input))
client := http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
t.Fatalf("client.Do: %v", err)
}
defer resp.Body.Close()
t.Logf("client.Do: %s %s\n", req.Method, req.URL)
if got := resp.StatusCode; got != http.StatusOK {
t.Errorf("response status: got %d, want %d", got, http.StatusOK)
}
out, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatalf("ioutil.ReadAll: %v", err)
}
if got := string(out); got != test.want {
t.Errorf("%s: got %q, want %q", test.label, got, test.want)
}
}
} | explode_data.jsonl/40657 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 428
} | [
2830,
3393,
11541,
1860,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
1273,
1314,
18569,
66573,
2271,
1155,
340,
52934,
1669,
9437,
81,
18424,
7121,
1860,
445,
7322,
497,
17130,
30944,
915,
340,
743,
1848,
1669,
2473,
34848,
1989,
2129,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestBroadcastChannelSupportRejection(t *testing.T) {
ledgerFactory, _ := NewRAMLedgerAndFactory(10)
mockConsenters := map[string]consensus.Consenter{conf.Orderer.OrdererType: &mockConsenter{}}
registrar := NewRegistrar(ledgerFactory, mockConsenters, mockCrypto())
randomValue := 1
configTx := makeConfigTx(genesisconfig.TestChainID, randomValue)
_, _, _, err := registrar.BroadcastChannelSupport(configTx)
assert.Error(t, err, "Messages of type HeaderType_CONFIG should return an error.")
} | explode_data.jsonl/71402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
43362,
9629,
7916,
693,
7606,
1155,
353,
8840,
836,
8,
341,
197,
50704,
4153,
11,
716,
1669,
1532,
49,
31102,
291,
1389,
3036,
4153,
7,
16,
15,
340,
77333,
15220,
306,
388,
1669,
2415,
14032,
60,
6254,
13626,
94594,
1950,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClient_IndexTxAttempts(t *testing.T) {
t.Parallel()
app, cleanup := cltest.NewApplicationWithKey(t, cltest.LenientEthMock)
defer cleanup()
require.NoError(t, app.Start())
store := app.GetStore()
from := cltest.GetAccountAddress(t, store)
tx := cltest.CreateTx(t, store, from, 1)
client, r := app.NewClientAndRenderer()
// page 1
set := flag.NewFlagSet("test txattempts", 0)
set.Int("page", 1, "doc")
c := cli.NewContext(nil, set, nil)
require.Equal(t, 1, c.Int("page"))
assert.NoError(t, client.IndexTxAttempts(c))
renderedAttempts := *r.Renders[0].(*[]models.TxAttempt)
require.Len(t, tx.Attempts, 1)
assert.Equal(t, tx.Attempts[0].Hash.Hex(), renderedAttempts[0].Hash.Hex())
// page 2 which doesn't exist
set = flag.NewFlagSet("test transactions", 0)
set.Int("page", 2, "doc")
c = cli.NewContext(nil, set, nil)
require.Equal(t, 2, c.Int("page"))
assert.NoError(t, client.IndexTxAttempts(c))
renderedAttempts = *r.Renders[1].(*[]models.TxAttempt)
assert.Equal(t, 0, len(renderedAttempts))
} | explode_data.jsonl/78860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 398
} | [
2830,
3393,
2959,
50361,
31584,
81517,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
28236,
11,
21290,
1669,
1185,
1944,
7121,
4988,
2354,
1592,
1155,
11,
1185,
1944,
65819,
1167,
65390,
11571,
340,
16867,
21290,
741,
17957,
3569... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAgent_Monitor(t *testing.T) {
t.Parallel()
logWriter := logger.NewLogWriter(512)
a := &TestAgent{
Name: t.Name(),
LogWriter: logWriter,
LogOutput: io.MultiWriter(os.Stderr, logWriter),
}
a.Start()
defer a.Shutdown()
// Try passing an invalid log level
req, _ := http.NewRequest("GET", "/v1/agent/monitor?loglevel=invalid", nil)
resp := newClosableRecorder()
if _, err := a.srv.AgentMonitor(resp, req); err != nil {
t.Fatalf("err: %v", err)
}
if resp.Code != 400 {
t.Fatalf("bad: %v", resp.Code)
}
body, _ := ioutil.ReadAll(resp.Body)
if !strings.Contains(string(body), "Unknown log level") {
t.Fatalf("bad: %s", body)
}
// Try to stream logs until we see the expected log line
retry.Run(t, func(r *retry.R) {
req, _ = http.NewRequest("GET", "/v1/agent/monitor?loglevel=debug", nil)
resp = newClosableRecorder()
done := make(chan struct{})
go func() {
if _, err := a.srv.AgentMonitor(resp, req); err != nil {
t.Fatalf("err: %s", err)
}
close(done)
}()
resp.Close()
<-done
got := resp.Body.Bytes()
want := []byte("raft: Initial configuration (index=1)")
if !bytes.Contains(got, want) {
r.Fatalf("got %q and did not find %q", got, want)
}
})
} | explode_data.jsonl/33647 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 518
} | [
2830,
3393,
16810,
1245,
30314,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
6725,
6492,
1669,
5925,
7121,
2201,
6492,
7,
20,
16,
17,
340,
11323,
1669,
609,
2271,
16810,
515,
197,
21297,
25,
414,
259,
2967,
3148,
197,
24201,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test1(t *testing.T) {
matcher := NewMatcher()
matcher.Insert("你是毛泽东吗", 30, []int64{0}, 265)
matcher.Insert("毛泽东啊", 30, []int64{0}, 265)
//matcher.Insert("邀请码", 30, []int64{0}, 265)
matcher.Build()
fmt.Println(matcher.Filter("你是毛泽东啊", 0, 15))
} | explode_data.jsonl/56863 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
16,
1155,
353,
8840,
836,
8,
341,
2109,
28058,
1669,
1532,
37554,
741,
2109,
28058,
23142,
445,
105043,
107033,
101037,
497,
220,
18,
15,
11,
3056,
396,
21,
19,
90,
15,
2137,
220,
17,
21,
20,
340,
2109,
28058,
23142,
445... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDuplicateKey(t *testing.T) {
expectConfigPanic(
t,
func() {
config.NewRateLimitConfigImpl(
loadFile("duplicate_key.yaml"),
stats.NewStore(stats.NewNullSink(), false))
},
"duplicate_key.yaml: duplicate descriptor composite key 'test-domain.key1_value1'")
} | explode_data.jsonl/41133 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
53979,
1592,
1155,
353,
8840,
836,
8,
341,
24952,
2648,
47,
31270,
1006,
197,
3244,
345,
197,
29244,
368,
341,
298,
25873,
7121,
11564,
16527,
2648,
9673,
1006,
571,
49386,
1703,
445,
63826,
3097,
33406,
4461,
571,
79659,
71... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFindInsertPoint(t *testing.T) {
type args struct {
doc string
docMarkerStart string
docMarkerEnd string
}
tests := []struct {
name string
args args
wantStart int
wantEnd int
err string
}{
{
name: "simple",
args: args{
doc: `lorem
ipsom
markerstart
dolor
markerend`,
docMarkerStart: "markerstart",
docMarkerEnd: "markerend"},
wantStart: 3,
wantEnd: 5,
},
{
name: "missing start marker",
args: args{
doc: `lorem
ipsom
dolor
markerend`,
docMarkerStart: "markerstart",
docMarkerEnd: "markerend"},
err: "unable to find start marker: markerstart",
},
{
name: "missing end marker",
args: args{
doc: `lorem
ipsom
markerstart
dolor`,
docMarkerStart: "markerstart",
docMarkerEnd: "markerend"},
err: "unable to find end marker: markerend",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotStart, gotEnd, err := findInsertPoint(strings.Split(tt.args.doc, "\n"), tt.args.docMarkerStart, tt.args.docMarkerEnd)
require := require.New(t)
if tt.err != "" {
require.EqualError(err, tt.err)
} else {
require.NoError(err)
require.Equal(tt.wantStart, gotStart)
require.Equal(tt.wantStart, gotEnd)
}
})
}
} | explode_data.jsonl/6196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 602
} | [
2830,
3393,
9885,
13780,
2609,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
59536,
310,
914,
198,
197,
59536,
20613,
3479,
914,
198,
197,
59536,
20613,
3727,
256,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestShouldNotHashPasswordDueToSaltCharLengthTooShort(t *testing.T) {
// The salt 'YQ' is the base64 value for 'a' which is why the length is 1.
hash, err := HashPassword("password", "YQ", HashingAlgorithmArgon2id,
schema.DefaultCIPasswordConfiguration.Iterations, schema.DefaultCIPasswordConfiguration.Memory*1024,
schema.DefaultCIPasswordConfiguration.Parallelism, schema.DefaultCIPasswordConfiguration.KeyLength,
schema.DefaultCIPasswordConfiguration.SaltLength)
assert.Equal(t, "", hash)
assert.EqualError(t, err, "Salt input of a is invalid (1 characters), it must be 8 or more characters")
} | explode_data.jsonl/40176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
14996,
2623,
6370,
4876,
33060,
1249,
47318,
4768,
4373,
31246,
12472,
1155,
353,
8840,
836,
8,
341,
197,
322,
576,
12021,
364,
56,
48,
6,
374,
279,
2331,
21,
19,
897,
369,
364,
64,
6,
892,
374,
3170,
279,
3084,
374,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAudioAnalysis(t *testing.T) {
c, s := testClientFile(http.StatusOK, "test_data/get_audio_analysis.txt")
defer s.Close()
analysis, err := c.GetAudioAnalysis("foo")
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(analysis.Bars, expected.Bars) {
t.Errorf(fieldsDifferTemplate, "Bars")
}
if !reflect.DeepEqual(analysis.Beats, expected.Beats) {
t.Errorf(fieldsDifferTemplate, "Beats")
}
if !reflect.DeepEqual(analysis.Meta, expected.Meta) {
t.Errorf(fieldsDifferTemplate, "Meta")
}
if !reflect.DeepEqual(analysis.Sections, expected.Sections) {
t.Errorf(fieldsDifferTemplate, "Sections")
}
if !reflect.DeepEqual(analysis.Segments, expected.Segments) {
t.Errorf(fieldsDifferTemplate, "Segments")
}
if !reflect.DeepEqual(analysis.Track, expected.Track) {
t.Errorf(fieldsDifferTemplate, "Track")
}
if !reflect.DeepEqual(analysis.Tatums, expected.Tatums) {
t.Errorf(fieldsDifferTemplate, "Tatums")
}
} | explode_data.jsonl/60308 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 370
} | [
2830,
3393,
14755,
26573,
1155,
353,
8840,
836,
8,
341,
1444,
11,
274,
1669,
1273,
2959,
1703,
19886,
52989,
11,
330,
1944,
1769,
23302,
29688,
42682,
3909,
1138,
16867,
274,
10421,
2822,
197,
34484,
11,
1848,
1669,
272,
2234,
14755,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestDockerKubernetes121UpgradeFromLatestMinorRelease(t *testing.T) {
provider := framework.NewDocker(t)
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterFiller(api.WithKubernetesVersion(anywherev1.Kube121)),
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
framework.WithClusterFiller(api.WithControlPlaneCount(1)),
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
)
runUpgradeFromLatestReleaseFlow(
test,
anywherev1.Kube121,
)
} | explode_data.jsonl/6566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
35,
13659,
42,
29827,
16,
17,
16,
43861,
3830,
31992,
57024,
16077,
1155,
353,
8840,
836,
8,
341,
197,
19979,
1669,
12626,
7121,
35,
13659,
1155,
340,
18185,
1669,
12626,
7121,
28678,
36,
17,
1348,
477,
1006,
197,
3244,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResolver_UserPermissionsInfo(t *testing.T) {
t.Run("authenticated as non-admin", func(t *testing.T) {
db.Mocks.Users.GetByCurrentAuthUser = func(context.Context) (*types.User, error) {
return &types.User{}, nil
}
t.Cleanup(func() {
db.Mocks.Users.GetByCurrentAuthUser = nil
})
ctx := actor.WithActor(context.Background(), &actor.Actor{UID: 1})
result, err := (&Resolver{}).UserPermissionsInfo(ctx, graphqlbackend.MarshalRepositoryID(1))
if want := backend.ErrMustBeSiteAdmin; err != want {
t.Errorf("err: want %q but got %v", want, err)
}
if result != nil {
t.Errorf("result: want nil but got %v", result)
}
})
db.Mocks.Users.GetByCurrentAuthUser = func(context.Context) (*types.User, error) {
return &types.User{SiteAdmin: true}, nil
}
db.Mocks.Users.GetByID = func(ctx context.Context, id int32) (*types.User, error) {
return &types.User{ID: id}, nil
}
edb.Mocks.Perms.LoadUserPermissions = func(_ context.Context, p *authz.UserPermissions) error {
p.UpdatedAt = clock()
p.SyncedAt = clock()
return nil
}
defer func() {
db.Mocks.Users = db.MockUsers{}
edb.Mocks.Perms = edb.MockPerms{}
}()
tests := []struct {
name string
gqlTests []*gqltesting.Test
}{
{
name: "get permissions information",
gqlTests: []*gqltesting.Test{
{
Schema: mustParseGraphQLSchema(t, nil),
Query: `
{
currentUser {
permissionsInfo {
permissions
syncedAt
updatedAt
}
}
}
`,
ExpectedResult: fmt.Sprintf(`
{
"currentUser": {
"permissionsInfo": {
"permissions": ["READ"],
"syncedAt": "%[1]s",
"updatedAt": "%[1]s"
}
}
}
`, clock().Format(time.RFC3339)),
},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
gqltesting.RunTests(t, test.gqlTests)
})
}
} | explode_data.jsonl/14720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 865
} | [
2830,
3393,
18190,
31339,
23851,
1731,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
57707,
438,
2477,
27225,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
20939,
24664,
82,
36782,
2234,
1359,
5405,
5087,
1474,
284,
2915,
5378,
9328,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTrie_InsertDuplicatePrefixes(t *testing.T) {
trie := NewTrie()
data := []testData{
{"Pepan", "Pepan Zdepan", success},
{"Pepan", "Pepan Zdepan", failure},
}
for _, v := range data {
t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
}
}
} | explode_data.jsonl/2356 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
51,
7231,
76417,
53979,
14335,
288,
1155,
353,
8840,
836,
8,
341,
197,
8927,
1669,
1532,
51,
7231,
2822,
8924,
1669,
3056,
1944,
1043,
515,
197,
197,
4913,
47,
747,
276,
497,
330,
47,
747,
276,
1863,
450,
848,
497,
2393,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_InboundIpRule_Status_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip from InboundIpRule_Status to InboundIpRule_Status via AssignPropertiesToInboundIpRuleStatus & AssignPropertiesFromInboundIpRuleStatus returns original",
prop.ForAll(RunPropertyAssignmentTestForInboundIpRuleStatus, InboundIpRuleStatusGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
} | explode_data.jsonl/39614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
25972,
10891,
23378,
11337,
36449,
62,
4498,
7903,
61941,
2568,
795,
21884,
1690,
26040,
39838,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTxWithPubMetadata(t *testing.T) {
for _, testEnv := range testEnvs {
t.Logf("Running test for TestEnv = %s", testEnv.getName())
testLedgerID := "testtxwithpubmetadata"
testEnv.init(t, testLedgerID, nil)
testTxWithPubMetadata(t, testEnv)
testEnv.cleanup()
}
} | explode_data.jsonl/63623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
31584,
2354,
29162,
14610,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
14359,
1669,
2088,
1273,
1702,
11562,
341,
197,
3244,
98954,
445,
18990,
1273,
369,
3393,
14359,
284,
1018,
82,
497,
1273,
14359,
8911,
2398,
197,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestInitTransactionWithRetries(t *testing.T) {
opts := &bind.TransactOpts{From: common.HexToAddress("0x45B9c4798999FFa52e1ff1eFce9d3e45819E4158")}
mockRequest := &MockTransactionRequest{}
// noncer success
mockClient := &MockEthCl{}
mockClient.On("PendingNonceAt", mock.Anything, opts.From).Return(uint64(1), nil)
gc := &gethClient{
txMu: sync.Mutex{},
config: cfg,
client: mockClient,
}
SetClient(gc)
// Success at first
tx, err := gc.SubmitTransactionWithRetries(mockRequest.RegisterTransaction, opts, "var1", "var2")
assert.Nil(t, err, "Should not error out")
assert.EqualValues(t, 1, tx.Nonce(), "Nonce should equal to the one provided")
assert.EqualValues(t, 1, mockRequest.count, "Transaction Run flag should be true")
// Failure with non-locking error
tx, err = gc.SubmitTransactionWithRetries(mockRequest.RegisterTransaction, opts, "otherError", "var2")
assert.EqualError(t, err, "Some other error", "Should error out")
mockRetries := testingutils.MockConfigOption(cfg, "ethereum.maxRetries", 10)
defer mockRetries()
mockRequest.count = 0
// Failure and timeout with locking error
tx, err = gc.SubmitTransactionWithRetries(mockRequest.RegisterTransaction, opts, "optimisticLockingTimeout", "var2")
assert.Contains(t, err.Error(), ErrTransactionUnderpriced, "Should error out")
assert.EqualValues(t, 10, mockRequest.count, "Retries should be equal")
mockRequest.count = 0
// Success after locking race condition overcome
tx, err = gc.SubmitTransactionWithRetries(mockRequest.RegisterTransaction, opts, "optimisticLockingEventualSuccess", "var2")
assert.Nil(t, err, "Should not error out")
assert.EqualValues(t, 3, mockRequest.count, "Retries should be equal")
} | explode_data.jsonl/53155 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 588
} | [
2830,
3393,
3803,
8070,
2354,
12020,
4019,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
609,
7666,
11815,
531,
43451,
90,
3830,
25,
4185,
91538,
1249,
4286,
445,
15,
87,
19,
20,
33,
24,
66,
19,
22,
24,
23,
24,
24,
24,
1748,
64,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOptions(t *testing.T) {
mysqld, err := NewMysqld(NewConfig())
if !assert.NoError(t, err, "NewMysqld should succeed") {
return
}
dsn := mysqld.Datasource(
"mysql",
"root",
"localhost",
0,
WithParseTime(true),
WithMultiStatements(true),
)
if !assert.Regexp(t, "parseTime=true", dsn, "dsn matches expected") {
return
}
if !assert.Regexp(t, "multiStatements=true", dsn, "dsn matches expected") {
return
}
} | explode_data.jsonl/77523 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
3798,
1155,
353,
8840,
836,
8,
341,
2109,
1047,
80,
507,
11,
1848,
1669,
1532,
44,
1047,
80,
507,
35063,
2648,
2398,
743,
753,
2207,
35699,
1155,
11,
1848,
11,
330,
3564,
44,
1047,
80,
507,
1265,
11996,
899,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestLifecycle(t *testing.T) {
err := checkpoint.CreateTable(local.DynamoDB, local.Env, 5, 5)
assert.Nil(t, err)
ctx := context.Background()
cp := checkpoint.New(local.Env, local.DynamoDB)
key := randx.AlphaN(12)
offset := uint64(randx.Int63())
err = cp.Save(ctx, key, offset)
assert.Nil(t, err)
actual, err := cp.Load(ctx, key)
assert.Nil(t, err)
assert.Equal(t, actual, offset)
err = cp.Save(ctx, key, offset-1)
assert.NotNil(t, err, "offsets cannot decrease")
err = cp.Save(ctx, key, offset)
assert.Nil(t, err, "save should be idempotent")
err = cp.Save(ctx, key, offset+1)
assert.Nil(t, err, "save should accept incrementing values")
actual, err = cp.Load(ctx, key)
assert.Nil(t, err)
assert.Equal(t, actual, offset+1)
} | explode_data.jsonl/7594 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
62731,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
29295,
55046,
18082,
909,
85608,
3506,
11,
2205,
81214,
11,
220,
20,
11,
220,
20,
340,
6948,
59678,
1155,
11,
1848,
692,
20985,
1669,
2266,
19047,
741,
52018,
1669,
29295,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAccAWSDBInstance_MSSQL_TZ(t *testing.T) {
var v rds.DBInstance
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSDBMSSQL_timezone,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists("aws_db_instance.mssql", &v),
testAccCheckAWSDBInstanceAttributes_MSSQL(&v, ""),
resource.TestCheckResourceAttr(
"aws_db_instance.mssql", "allocated_storage", "20"),
resource.TestCheckResourceAttr(
"aws_db_instance.mssql", "engine", "sqlserver-ex"),
),
},
{
Config: testAccAWSDBMSSQL_timezone_AKST,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists("aws_db_instance.mssql", &v),
testAccCheckAWSDBInstanceAttributes_MSSQL(&v, "Alaskan Standard Time"),
resource.TestCheckResourceAttr(
"aws_db_instance.mssql", "allocated_storage", "20"),
resource.TestCheckResourceAttr(
"aws_db_instance.mssql", "engine", "sqlserver-ex"),
),
},
},
})
} | explode_data.jsonl/33928 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 491
} | [
2830,
3393,
14603,
36136,
3506,
2523,
1245,
1220,
3588,
1139,
57,
1155,
353,
8840,
836,
8,
341,
2405,
348,
435,
5356,
22537,
2523,
271,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
257,
2915,
368,
314,
1273,
1460... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetClusters(t *testing.T) {
t.Run("could not create in cluster config", func(t *testing.T) {
getInClusterConfig = getInClusterConfigError
client := New(&Config{Name: "kobs"})
clusters, err := client.GetCluster()
require.Error(t, err)
require.Empty(t, clusters)
})
t.Run("new cluster fails", func(t *testing.T) {
getInClusterConfig = getInClusterConfigSuccess
getNewCluster = getNewClusterTestError
client := New(&Config{Name: "kobs"})
clusters, err := client.GetCluster()
require.Error(t, err)
require.Empty(t, clusters)
})
t.Run("new cluster", func(t *testing.T) {
getInClusterConfig = getInClusterConfigSuccess
getNewCluster = getNewClusterTestSuccess
client := New(&Config{Name: "kobs"})
clusters, err := client.GetCluster()
require.NoError(t, err)
require.NotEmpty(t, clusters)
})
} | explode_data.jsonl/34214 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 314
} | [
2830,
3393,
1949,
94992,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
28077,
537,
1855,
304,
10652,
2193,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
10366,
641,
28678,
2648,
284,
633,
641,
28678,
2648,
1454,
271,
197,
25291,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValues_MarshalUnmarshalJSON(t *testing.T) {
values := Values{
Data: map[string]interface{}{
"key": "value",
},
}
expected := `{"key":"value"}`
actual, err := values.MarshalJSON()
if err != nil {
t.Errorf("unexpected error: %v", err)
}
assert.Equal(t, expected, string(actual))
var values2 Values
err = values2.UnmarshalJSON(actual)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
assert.Equal(t, values, values2)
} | explode_data.jsonl/4722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
6227,
1245,
28423,
1806,
27121,
5370,
1155,
353,
8840,
836,
8,
341,
45939,
1669,
24979,
515,
197,
40927,
25,
2415,
14032,
31344,
67066,
298,
197,
1,
792,
788,
330,
957,
756,
197,
197,
1583,
197,
630,
42400,
1669,
1565,
491... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFlagUnderscoreRenaming(t *testing.T) {
factory := NewFactory(nil)
factory.FlagSet().SetNormalizeFunc(flag.WordSepNormalizeFunc)
factory.FlagSet().Bool("valid_flag", false, "bool value")
// In case of failure of this test check this PR: spf13/pflag#23
if factory.FlagSet().Lookup("valid_flag").Name != "valid-flag" {
t.Fatalf("Expected flag name to be valid-flag, got %s", factory.FlagSet().Lookup("valid_flag").Name)
}
} | explode_data.jsonl/43206 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
12135,
19957,
388,
2153,
34625,
6469,
1155,
353,
8840,
836,
8,
341,
1166,
2919,
1669,
1532,
4153,
27907,
692,
1166,
2919,
80911,
1649,
1005,
1649,
87824,
9626,
33104,
64969,
41114,
87824,
9626,
340,
1166,
2919,
80911,
1649,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReaderAt(t *testing.T) {
svc := s3.New(unit.Session)
svc.Handlers.Unmarshal.Clear()
svc.Handlers.UnmarshalMeta.Clear()
svc.Handlers.UnmarshalError.Clear()
svc.Handlers.Send.Clear()
contentLen := ""
svc.Handlers.Send.PushBack(func(r *request.Request) {
contentLen = r.HTTPRequest.Header.Get("Content-Length")
r.HTTPResponse = &http.Response{
StatusCode: 200,
Body: ioutil.NopCloser(bytes.NewReader([]byte{})),
}
})
mgr := s3manager.NewUploaderWithClient(svc, func(u *s3manager.Uploader) {
u.Concurrency = 1
})
_, err := mgr.Upload(&s3manager.UploadInput{
Bucket: aws.String("Bucket"),
Key: aws.String("Key"),
Body: &fooReaderAt{},
})
if err != nil {
t.Errorf("Expected no error but received %v", err)
}
if e, a := "12", contentLen; e != a {
t.Errorf("Expected %q, but received %q", e, a)
}
} | explode_data.jsonl/55652 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 373
} | [
2830,
3393,
5062,
1655,
1155,
353,
8840,
836,
8,
341,
1903,
7362,
1669,
274,
18,
7121,
24144,
20674,
340,
1903,
7362,
35308,
9254,
38097,
13524,
741,
1903,
7362,
35308,
9254,
38097,
12175,
13524,
741,
1903,
7362,
35308,
9254,
38097,
1454,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_NamespacesTopics_Spec_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip of NamespacesTopics_Spec via JSON returns original",
prop.ForAll(RunJSONSerializationTestForNamespacesTopicsSpec, NamespacesTopicsSpecGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
} | explode_data.jsonl/36550 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
1604,
971,
27338,
45003,
1098,
992,
62,
4498,
77521,
78967,
98054,
2848,
4756,
2121,
2993,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMultiCellVreplicationWorkflow(t *testing.T) {
cells := []string{"zone1", "zone2"}
allCellNames = "zone1,zone2"
vc = NewVitessCluster(t, "TestMultiCellVreplicationWorkflow", cells, mainClusterConfig)
require.NotNil(t, vc)
defaultCellName := "zone1"
defaultCell = vc.Cells[defaultCellName]
defer vc.TearDown(t)
cell1 := vc.Cells["zone1"]
cell2 := vc.Cells["zone2"]
vc.AddKeyspace(t, []*Cell{cell1, cell2}, "product", "0", initialProductVSchema, initialProductSchema, defaultReplicas, defaultRdonly, 100)
vtgate = cell1.Vtgates[0]
require.NotNil(t, vtgate)
vtgate.WaitForStatusOfTabletInShard(fmt.Sprintf("%s.%s.primary", "product", "0"), 1)
vtgate.WaitForStatusOfTabletInShard(fmt.Sprintf("%s.%s.replica", "product", "0"), 2)
vtgateConn = getConnection(t, vc.ClusterConfig.hostname, vc.ClusterConfig.vtgateMySQLPort)
defer vtgateConn.Close()
verifyClusterHealth(t, vc)
insertInitialData(t)
shardCustomer(t, true, []*Cell{cell1, cell2}, cell2.Name, true)
} | explode_data.jsonl/44950 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 399
} | [
2830,
3393,
20358,
3599,
53,
9995,
1693,
62768,
1155,
353,
8840,
836,
8,
341,
1444,
6436,
1669,
3056,
917,
4913,
8684,
16,
497,
330,
8684,
17,
16707,
50960,
3599,
7980,
284,
330,
8684,
16,
11,
8684,
17,
1837,
5195,
66,
284,
1532,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_SystemData_Status_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip from SystemData_Status to SystemData_Status via AssignPropertiesToSystemDataStatus & AssignPropertiesFromSystemDataStatus returns original",
prop.ForAll(RunPropertyAssignmentTestForSystemDataStatus, SystemDataStatusGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
} | explode_data.jsonl/39622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
25363,
1043,
36449,
62,
4498,
7903,
61941,
2568,
795,
21884,
1690,
26040,
39838,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
220,
16,
15,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStartTransaction_given_envelope_with_trace_context_headers_when_start_transaction_called_it_will_return_transaction_with_proper_parent(t *testing.T) {
tracer := apmtest.NewDiscardTracer()
var e messenger.Envelope = envelope.FromMessage("test message")
e = envelope.WithHeader(e, TraceparentHeader, "00-8475ef5f80f95de1f3bbcc1c7c64b7c9-8475ef5f80f95de1-01")
e = envelope.WithHeader(e, TracestateHeader, "es=s:1")
tx := StartTransaction(tracer, "Test transaction", "test", e)
assert.NotEmpty(t, tx)
assert.Equal(t, "Test transaction", tx.Name)
assert.Equal(t, "test", tx.Type)
assert.Equal(t, "8475ef5f80f95de1", tx.ParentID().String())
assert.Equal(t, "8475ef5f80f95de1f3bbcc1c7c64b7c9", tx.TraceContext().Trace.String())
} | explode_data.jsonl/46776 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
3479,
8070,
57653,
6205,
18853,
6615,
23575,
8467,
26719,
47636,
4906,
28884,
27859,
14631,
1670,
483,
12511,
28884,
6615,
2540,
712,
15960,
1155,
353,
8840,
836,
8,
341,
25583,
9584,
1669,
1443,
76,
1944,
7121,
23477,
567,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHelloExtensionsUnmarshal_NoExtensions(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
val := recordfmt.HelloExtensions{recordfmt.HelloExtension{}}
if err := val.Decode(buf); len(val) != 0 || err != nil {
t.Fatal(val, err)
}
} | explode_data.jsonl/53624 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
9707,
31282,
1806,
27121,
36989,
31282,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
5820,
7121,
4095,
10556,
3782,
37790,
19302,
1669,
3255,
12501,
3839,
4791,
31282,
90,
8548,
12501,
3839,
4791,
12049,
6257,
630,
743,
1848,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_PostBlockFail(t *testing.T) {
chain, mock33 := createBlockChain(t)
ps := &bcMocks.PostService{}
ps.On("PostData", mock.Anything, mock.Anything, mock.Anything).Return(errors.New("timeout"))
chain.push.postService = ps
subscribe := new(types.PushSubscribeReq)
subscribe.Name = "push-test"
subscribe.URL = "http://localhost"
subscribe.Type = PushBlock
err := chain.push.addSubscriber(subscribe)
time.Sleep(2 * time.Second)
assert.Equal(t, err, nil)
createBlocks(t, mock33, chain, 10)
keyStr := string(calcPushKey(subscribe.Name))
pushNotify := chain.push.tasks[keyStr]
assert.Equal(t, pushNotify.subscribe.Name, subscribe.Name)
assert.Equal(t, pushNotify.status, running)
time.Sleep(1 * time.Second)
createBlocks(t, mock33, chain, 1)
assert.Greater(t, atomic.LoadInt32(&pushNotify.postFail2Sleep), int32(0))
time.Sleep(1 * time.Second)
lastSeq, _ := chain.ProcGetLastPushSeq(subscribe.Name)
assert.Equal(t, lastSeq, int64(-1))
mock33.Close()
} | explode_data.jsonl/61719 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 371
} | [
2830,
3393,
66726,
4713,
19524,
1155,
353,
8840,
836,
8,
341,
197,
8819,
11,
7860,
18,
18,
1669,
1855,
4713,
18837,
1155,
340,
35009,
1669,
609,
8904,
72577,
23442,
1860,
16094,
35009,
8071,
445,
4133,
1043,
497,
7860,
13311,
1596,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResolveCached(t *testing.T) {
servers := Servers{
"A",
"B",
"C",
}
miss := 0
rslv := &CachedResolver{
Resolver: ResolverFunc(func(ctx context.Context) ([]string, error) {
miss++
return servers.Resolve(ctx)
}),
Timeout: 10 * time.Millisecond,
}
ctx, cancel := context.WithCancel(context.Background())
for i := 0; i != 3; i++ {
for j := 0; j != 10; j++ {
res, err := rslv.Resolve(ctx)
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(res, ([]string)(servers)) {
t.Error(res)
}
}
if miss != (i + 1) {
t.Error("too many cache misses:", miss)
}
// Sleep for a little while so the cache entry expires.
time.Sleep(20 * time.Millisecond)
}
cancel()
_, err := rslv.Resolve(ctx)
if err == nil {
t.Error("bad error after the context was canceled:", err)
}
} | explode_data.jsonl/38860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 367
} | [
2830,
3393,
56808,
70293,
1155,
353,
8840,
836,
8,
341,
1903,
18729,
1669,
71797,
515,
197,
197,
29133,
756,
197,
197,
63590,
756,
197,
197,
46316,
756,
197,
630,
197,
1831,
1669,
220,
15,
198,
7000,
3226,
85,
1669,
609,
70293,
18190,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStoryServiceDeleteStory(t *testing.T) {
testCases := map[string]struct {
input func() (string, store.StoriesStore)
expectedCount int64
expectedError error
}{
"test delete story success": {
input: func() (string, store.StoriesStore) {
id := "2eaa0697-2572-47f9-bcff-0bdf0c7c6432"
str, err := model.NewStoryBuilder().
SetTitle(100, "title").
SetBody(100, "test body").
Build()
require.NoError(t, err)
str.ID = id
mst := &store.MockStoriesStore{}
mst.On("DeleteStory", str.GetID()).Return(int64(1), nil)
return id, mst
},
expectedCount: 1,
},
"test delete story failure": {
input: func() (string, store.StoriesStore) {
id := "2eaa0697-2572-47f9-bcff-0bdf0c7c6432"
str, err := model.NewStoryBuilder().
SetTitle(100, "title").
SetBody(100, "test body").
Build()
require.NoError(t, err)
str.ID = id
mst := &store.MockStoriesStore{}
mst.On("DeleteStory", str.GetID()).Return(int64(0), liberr.WithArgs(errors.New("failed to delete story")))
return id, mst
},
expectedCount: 0,
expectedError: errors.New("failed to delete story"),
},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
id, str := testCase.input()
svc := service.NewStoriesService(str)
res, err := svc.DeleteStory(id)
if testCase.expectedError != nil {
assert.Equal(t, testCase.expectedError.Error(), err.Error())
} else {
assert.Nil(t, err)
}
assert.Equal(t, testCase.expectedCount, res)
})
}
} | explode_data.jsonl/44022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 689
} | [
2830,
3393,
17938,
1860,
6435,
17938,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
22427,
260,
2915,
368,
320,
917,
11,
3553,
7758,
2433,
6093,
340,
197,
42400,
2507,
526,
21,
19,
198,
197,
42400,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test(t *testing.T) {
cfg := &Config{}
cfg.Default()
inf, err := NewInformer(cfg)
if err != nil {
t.Fatal(err)
}
m := inf.GetMetric()
if m.Valid {
t.Error("metric should be invalid")
}
inf.SetClient(mockRPCClient(t))
m = inf.GetMetric()
if !m.Valid {
t.Error("metric should be valid")
}
if m.Value != "2" {
t.Error("bad metric value")
}
} | explode_data.jsonl/38075 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
609,
2648,
16094,
50286,
13275,
741,
197,
13573,
11,
1848,
1669,
1532,
641,
34527,
28272,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
2109,
1669,
4132,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestLookupHashMapAbsent(t *testing.T) {
lookuphash := createLookup(t, "lookup_hash", false)
vc := &vcursor{numRows: 0}
got, err := lookuphash.Map(vc, []sqltypes.Value{sqltypes.NewInt64(1), sqltypes.NewInt64(2)})
if err != nil {
t.Error(err)
}
want := []key.Destination{
key.DestinationNone{},
key.DestinationNone{},
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Map(): %#v, want %+v", got, want)
}
// writeOnly true should return full keyranges.
lookuphash = createLookup(t, "lookup_hash", true)
got, err = lookuphash.Map(vc, []sqltypes.Value{sqltypes.NewInt64(1), sqltypes.NewInt64(2)})
if err != nil {
t.Error(err)
}
want = []key.Destination{
key.DestinationKeyRange{
KeyRange: &topodatapb.KeyRange{},
},
key.DestinationKeyRange{
KeyRange: &topodatapb.KeyRange{},
},
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Map(): %#v, want %+v", got, want)
}
} | explode_data.jsonl/3417 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
3393,
34247,
18497,
80251,
1155,
353,
8840,
836,
8,
341,
197,
21020,
8296,
1669,
1855,
34247,
1155,
11,
330,
21020,
8950,
497,
895,
340,
5195,
66,
1669,
609,
7362,
3823,
90,
2413,
9024,
25,
220,
15,
630,
3174,
354,
11,
1848,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestLtField(t *testing.T) {
validate := New()
type TimeTest struct {
Start *time.Time `validate:"required,lt,ltfield=End"`
End *time.Time `validate:"required,lt"`
}
now := time.Now()
start := now.Add(time.Hour * 24 * -1 * 2)
end := start.Add(time.Hour * 24)
timeTest := &TimeTest{
Start: &start,
End: &end,
}
errs := validate.Struct(timeTest)
Equal(t, errs, nil)
timeTest = &TimeTest{
Start: &end,
End: &start,
}
errs = validate.Struct(timeTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "TimeTest.Start", "TimeTest.Start", "Start", "Start", "ltfield")
errs = validate.VarWithValue(&start, &end, "ltfield")
Equal(t, errs, nil)
errs = validate.VarWithValue(&end, &start, "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
errs = validate.VarWithValue(&end, timeTest, "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
errs = validate.VarWithValue("tes", "test", "ltfield")
Equal(t, errs, nil)
type IntTest struct {
Val1 int `validate:"required"`
Val2 int `validate:"required,ltfield=Val1"`
}
intTest := &IntTest{
Val1: 5,
Val2: 1,
}
errs = validate.Struct(intTest)
Equal(t, errs, nil)
intTest = &IntTest{
Val1: 1,
Val2: 5,
}
errs = validate.Struct(intTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "IntTest.Val2", "IntTest.Val2", "Val2", "Val2", "ltfield")
errs = validate.VarWithValue(int(1), int(5), "ltfield")
Equal(t, errs, nil)
errs = validate.VarWithValue(int(5), int(1), "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
type UIntTest struct {
Val1 uint `validate:"required"`
Val2 uint `validate:"required,ltfield=Val1"`
}
uIntTest := &UIntTest{
Val1: 5,
Val2: 1,
}
errs = validate.Struct(uIntTest)
Equal(t, errs, nil)
uIntTest = &UIntTest{
Val1: 1,
Val2: 5,
}
errs = validate.Struct(uIntTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "UIntTest.Val2", "UIntTest.Val2", "Val2", "Val2", "ltfield")
errs = validate.VarWithValue(uint(1), uint(5), "ltfield")
Equal(t, errs, nil)
errs = validate.VarWithValue(uint(5), uint(1), "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
type FloatTest struct {
Val1 float64 `validate:"required"`
Val2 float64 `validate:"required,ltfield=Val1"`
}
floatTest := &FloatTest{
Val1: 5,
Val2: 1,
}
errs = validate.Struct(floatTest)
Equal(t, errs, nil)
floatTest = &FloatTest{
Val1: 1,
Val2: 5,
}
errs = validate.Struct(floatTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "FloatTest.Val2", "FloatTest.Val2", "Val2", "Val2", "ltfield")
errs = validate.VarWithValue(float32(1), float32(5), "ltfield")
Equal(t, errs, nil)
errs = validate.VarWithValue(float32(5), float32(1), "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
errs = validate.VarWithValue(nil, 5, "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
errs = validate.VarWithValue(1, "T", "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
errs = validate.VarWithValue(1, end, "ltfield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "ltfield")
type TimeTest2 struct {
Start *time.Time `validate:"required"`
End *time.Time `validate:"required,ltfield=NonExistantField"`
}
timeTest2 := &TimeTest2{
Start: &end,
End: &start,
}
errs = validate.Struct(timeTest2)
NotEqual(t, errs, nil)
AssertError(t, errs, "TimeTest2.End", "TimeTest2.End", "End", "End", "ltfield")
} | explode_data.jsonl/77298 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1590
} | [
2830,
3393,
87660,
1877,
1155,
353,
8840,
836,
8,
1476,
197,
7067,
1669,
1532,
2822,
13158,
4120,
2271,
2036,
341,
197,
65999,
353,
1678,
16299,
1565,
7067,
2974,
6279,
11,
4832,
11,
4832,
2566,
28,
3727,
8805,
197,
38407,
256,
353,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNonFailedBatchByBaseAndPullsIndexFunc(t *testing.T) {
successFullBatchJob := func(mods ...func(*prowapi.ProwJob)) *prowapi.ProwJob {
pj := &prowapi.ProwJob{
Spec: prowapi.ProwJobSpec{
Type: prowapi.BatchJob,
Job: "my-job",
Refs: &prowapi.Refs{
Org: "org",
Repo: "repo",
BaseRef: "master",
BaseSHA: "base-sha",
Pulls: []prowapi.Pull{
{
Number: 1,
SHA: "1",
},
{
Number: 2,
SHA: "2",
},
},
},
},
Status: prowapi.ProwJobStatus{
State: prowapi.SuccessState,
CompletionTime: &metav1.Time{},
},
}
for _, mod := range mods {
mod(pj)
}
return pj
}
const defaultIndexKey = "my-job|org|repo|master|base-sha|1|1|2|2"
testCases := []struct {
name string
pj *prowapi.ProwJob
expected []string
}{
{
name: "Basic success",
pj: successFullBatchJob(),
expected: []string{defaultIndexKey},
},
{
name: "Pulls reordered, same index",
pj: successFullBatchJob(func(pj *prowapi.ProwJob) {
pj.Spec.Refs.Pulls = []prowapi.Pull{
pj.Spec.Refs.Pulls[1],
pj.Spec.Refs.Pulls[0],
}
}),
expected: []string{defaultIndexKey},
},
{
name: "Not completed, state is ignored",
pj: successFullBatchJob(func(pj *prowapi.ProwJob) {
pj.Status.CompletionTime = nil
pj.Status.State = prowapi.TriggeredState
}),
expected: []string{defaultIndexKey},
},
{
name: "Different name, different index",
pj: successFullBatchJob(func(pj *prowapi.ProwJob) {
pj.Spec.Job = "my-other-job"
}),
expected: []string{"my-other-job|org|repo|master|base-sha|1|1|2|2"},
},
{
name: "Not a batch, ignored",
pj: successFullBatchJob(func(pj *prowapi.ProwJob) {
pj.Spec.Type = prowapi.PresubmitJob
}),
},
{
name: "No refs, ignored",
pj: successFullBatchJob(func(pj *prowapi.ProwJob) {
pj.Spec.Refs = nil
}),
},
}
for _, tc := range testCases {
result := nonFailedBatchByNameBaseAndPullsIndexFunc(tc.pj)
if diff := deep.Equal(result, tc.expected); diff != nil {
t.Errorf("Result differs from expected, diff: %v", diff)
}
}
} | explode_data.jsonl/42798 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1108
} | [
2830,
3393,
8121,
9408,
21074,
1359,
3978,
3036,
36068,
82,
1552,
9626,
1155,
353,
8840,
836,
8,
341,
30553,
9432,
21074,
12245,
1669,
2915,
23351,
82,
2503,
2830,
4071,
79,
651,
2068,
1069,
651,
12245,
593,
353,
79,
651,
2068,
1069,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSelectNext(t *testing.T) {
executor, _, _, sbclookup := createLegacyExecutorEnv()
query := "select next :n values from user_seq"
bv := map[string]*querypb.BindVariable{"n": sqltypes.Int64BindVariable(2)}
_, err := executorExec(executor, query, bv)
require.NoError(t, err)
wantQueries := []*querypb.BoundQuery{{
Sql: query,
BindVariables: map[string]*querypb.BindVariable{"n": sqltypes.Int64BindVariable(2)},
}}
if !reflect.DeepEqual(sbclookup.Queries, wantQueries) {
t.Errorf("sbclookup.Queries:\n%v, want\n%v\n", sbclookup.Queries, wantQueries)
}
} | explode_data.jsonl/67380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
3379,
5847,
1155,
353,
8840,
836,
8,
341,
67328,
4831,
11,
8358,
8358,
7898,
66,
21020,
1669,
1855,
77415,
25255,
14359,
2822,
27274,
1669,
330,
1742,
1790,
549,
77,
2750,
504,
1196,
14486,
698,
2233,
85,
1669,
2415,
14032,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetS2IPaths(t *testing.T) {
tests := []struct {
name string
podEnvs []corev1.EnvVar
want []string
}{
{
name: "Case 1: odo expected s2i envs available",
podEnvs: []corev1.EnvVar{
{
Name: occlient.EnvS2IDeploymentDir,
Value: "abc",
},
{
Name: occlient.EnvS2ISrcOrBinPath,
Value: "def",
},
{
Name: occlient.EnvS2IWorkingDir,
Value: "ghi",
},
{
Name: occlient.EnvS2ISrcBackupDir,
Value: "ijk",
},
},
want: []string{
filepath.FromSlash("abc/src"),
filepath.FromSlash("def/src"),
filepath.FromSlash("ghi/src"),
filepath.FromSlash("ijk/src"),
},
},
{
name: "Case 2: some of the odo expected s2i envs not available",
podEnvs: []corev1.EnvVar{
{
Name: occlient.EnvS2IDeploymentDir,
Value: "abc",
},
{
Name: occlient.EnvS2ISrcOrBinPath,
Value: "def",
},
{
Name: occlient.EnvS2ISrcBackupDir,
Value: "ijk",
},
},
want: []string{
filepath.FromSlash("abc/src"),
filepath.FromSlash("def/src"),
filepath.FromSlash("ijk/src"),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := getS2IPaths(tt.podEnvs)
sort.Strings(got)
sort.Strings(tt.want)
if !reflect.DeepEqual(tt.want, got) {
t.Errorf("got: %+v, want: %+v", got, tt.want)
}
})
}
} | explode_data.jsonl/4411 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 762
} | [
2830,
3393,
1949,
50,
17,
40,
26901,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
3223,
347,
1702,
11562,
3056,
98645,
16,
81214,
3962,
198,
197,
50780,
262,
3056,
917,
198,
197,
59403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBuildTree(t *testing.T) {
input := []int{3,9,20,-1,-1,15,7}
tree := NewTree(input)
print := levelOrder(tree)
if tree != nil {
t.Logf("level order print: %v", print)
}
} | explode_data.jsonl/50196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
11066,
6533,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
3056,
396,
90,
18,
11,
24,
11,
17,
15,
4999,
16,
4999,
16,
11,
16,
20,
11,
22,
532,
51968,
1669,
1532,
6533,
5384,
340,
6900,
1669,
2188,
4431,
21298,
340,
743,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDeletedMemberRollIsAlwaysAllowed(t *testing.T) {
roll := newMemberRoll("not-default", "istio-system")
roll.DeletionTimestamp = now()
validator, _, _ := createMemberRollValidatorTestFixture(smcp)
response := validator.Handle(ctx, createCreateRequest(roll))
assert.True(response.Allowed, "Expected validator to allow deleted ServiceMeshMemberRoll", t)
} | explode_data.jsonl/70260 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
26039,
9366,
32355,
3872,
37095,
35382,
1155,
353,
8840,
836,
8,
341,
197,
1100,
1669,
501,
9366,
32355,
445,
1921,
13672,
497,
330,
380,
815,
36648,
1138,
197,
1100,
8934,
52625,
20812,
284,
1431,
2822,
197,
16112,
11,
8358... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPrintBasicColor(t *testing.T) {
fmt.Println("Foreground colors:")
for name, c := range FgColors {
c.Print(" ", name, " ")
}
fmt.Println("\nBackground colors:")
for name, c := range BgColors {
c.Print(" ", name, " ")
}
fmt.Println("\nBasic Options:")
for name, c := range AllOptions {
c.Print(" ", name, " ")
}
fmt.Println("\nExtra foreground colors:")
for name, c := range ExFgColors {
c.Print(" ", name, " ")
}
fmt.Println("\nExtra background colors:")
for name, c := range ExBgColors {
c.Print(" ", name, " ")
}
fmt.Println()
fmt.Println()
} | explode_data.jsonl/7005 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
8994,
15944,
1636,
1155,
353,
8840,
836,
8,
341,
11009,
12419,
445,
25982,
7987,
34403,
2023,
829,
11,
272,
1669,
2088,
434,
70,
13108,
341,
197,
1444,
7918,
445,
3670,
829,
11,
330,
14167,
197,
630,
11009,
12419,
4921,
77... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestReExportDefaultInternal(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
export {default as foo} from './foo'
export {default as bar} from './bar'
`,
"/foo.js": `
export default 'foo'
`,
"/bar.js": `
export default 'bar'
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
},
})
} | explode_data.jsonl/38549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
693,
16894,
3675,
11569,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
59440,
314,
2258,
438,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInt(t *testing.T) {
e := 42
o := dummys.Get("someInt")
if v := o.Int(); v != e {
t.Errorf("expected %#v, got %#v", e, v)
}
if i := int(o.Interface().(float64)); i != e {
t.Errorf("expected %#v, got %#v", e, i)
}
if dummys.Set("otherInt", e); dummys.Get("otherInt").Int() != e {
t.Fail()
}
} | explode_data.jsonl/56771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
1072,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
220,
19,
17,
198,
22229,
1669,
62711,
8209,
2234,
445,
14689,
1072,
1138,
743,
348,
1669,
297,
7371,
2129,
348,
961,
384,
341,
197,
3244,
13080,
445,
7325,
52406,
85,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestPrint_bash_args(t *testing.T) {
// replace out (os.Stdout) by a buffer
bak := out
out = new(bytes.Buffer)
defer func() { out = bak }()
//tables := []struct{
// input map[string]interface{}
// expect []string
//}{
// {
// map[string]interface{}{ "FILE" : []string{"pipo", "molo", "toto"} },
// []string{
// "declare -A args",
// "args['FILE,0']='pipo'",
// "args['FILE,1']='molo'",
// "args['FILE,2']='toto'",
// "args['FILE,#']=3",
// },
// },
// {
// map[string]interface{}{ "--counter" : 2 },
// []string{
// "declare -A args",
// "args['--counter']=2",
// },
// },
// {
// map[string]interface{}{ "--counter" : "2" },
// []string{
// "declare -A args",
// "args['--counter']='2'",
// },
// },
// {
// map[string]interface{}{ "bool" : true },
// []string{
// "declare -A args",
// "args['bool']=true",
// },
// },
//}
d := &Docopts{
Global_prefix: "",
Mangle_key: true,
Output_declare: true,
}
tables, _ := test_json_loader.Load_json("./common_input_test.json")
for _, table := range tables {
d.Print_bash_args("args", table.Input)
res := out.(*bytes.Buffer).String()
expect := strings.Join(table.Expect_args[:],"\n") + "\n"
if res != expect {
t.Errorf("Print_bash_args for '%v'\ngot: '%v'\nwant: '%v'\n", table.Input, res, expect)
}
out.(*bytes.Buffer).Reset()
}
} | explode_data.jsonl/35248 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 849
} | [
2830,
3393,
8994,
880,
988,
8384,
1155,
353,
8840,
836,
8,
341,
262,
442,
8290,
700,
320,
436,
83225,
8,
553,
264,
4147,
198,
262,
36203,
1669,
700,
198,
262,
700,
284,
501,
23158,
22622,
340,
262,
17956,
2915,
368,
314,
700,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSynthesize(t *testing.T) {
testCases := []struct {
name string
input interface{}
expected map[string]interface{}
}{
{
name: "empty input",
input: &MyType{},
expected: map[string]interface{}{"bar": 0, "foo": ""},
},
{
name: "standard fields",
input: &MyType{Foo: "bar", Bar: 5},
expected: map[string]interface{}{
"bar": 5,
"foo": "bar",
},
},
{
name: "embedded fields",
input: &MyTypeEmbedded{
Foo: "bar",
Bar: 5,
Meta: Meta{
Name: "baz",
Namespace: "default",
Labels: map[string]string{"Hi": "hello"},
Annotations: map[string]string{"One": "1", "Two": "2"},
},
NotEmbedded: Meta{
Name: "not-baz",
Namespace: "not-default",
Labels: map[string]string{},
Annotations: map[string]string{},
},
},
expected: map[string]interface{}{
"bar": 5,
"foo": "bar",
"name": "baz",
"namespace": "default",
"labels": map[string]interface{}{
"Hi": "hello",
},
"annotations": map[string]interface{}{
"One": "1",
"Two": "2",
},
"not-embed": map[string]interface{}{
"name": "not-baz",
"namespace": "not-default",
"labels": map[string]interface{}{},
"annotations": map[string]interface{}{},
},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := Synthesize(tc.input)
assert.Equal(t, tc.expected, reflect.ValueOf(result).Interface())
})
}
} | explode_data.jsonl/68918 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 784
} | [
2830,
3393,
37134,
26887,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
22427,
262,
3749,
16094,
197,
42400,
2415,
14032,
31344,
16094,
197,
59403,
197,
197,
515,
298,
11609,
25,
257,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestZipAndEndocde(t *testing.T) {
for _, c := range [][]byte{
[]byte("abc123"),
[]byte("<a>abc</a>"),
[]byte("[\"a\":{\"b\":\"c\"}]"),
} {
r1, err := ZipAndEncode(c)
if err != nil {
t.Errorf("ZipAndEncode(%v) = %v", c, err)
continue
}
r2, err := UnzipAndDecode(r1)
if err != nil {
t.Errorf("UnzipAndDecode(%v) = %v", r1, err)
continue
}
if got, want := r2, c; string(got) != string(want) {
t.Errorf("UnzipAndDecode(ZipAndEncode()) = %v, want %v", got, want)
}
}
} | explode_data.jsonl/80317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
31047,
3036,
3727,
509,
450,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
272,
1669,
2088,
52931,
3782,
515,
197,
197,
1294,
3782,
445,
13683,
16,
17,
18,
4461,
197,
197,
1294,
3782,
9639,
64,
29,
13683,
522,
64,
29,
4461,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestCovarianceMatrix(t *testing.T) {
for _, test := range []struct {
mu []float64
sigma *mat.SymDense
}{
{
mu: []float64{2, 3, 4},
sigma: mat.NewSymDense(3, []float64{1, 0.5, 3, 0.5, 8, -1, 3, -1, 15}),
},
} {
normal, ok := NewNormal(test.mu, test.sigma, nil)
if !ok {
t.Fatalf("Bad test, covariance matrix not positive definite")
}
var cov mat.SymDense
normal.CovarianceMatrix(&cov)
if !mat.EqualApprox(&cov, test.sigma, 1e-14) {
t.Errorf("Covariance mismatch with nil input")
}
dim := test.sigma.Symmetric()
cov = *mat.NewSymDense(dim, nil)
normal.CovarianceMatrix(&cov)
if !mat.EqualApprox(&cov, test.sigma, 1e-14) {
t.Errorf("Covariance mismatch with supplied input")
}
}
} | explode_data.jsonl/12024 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
34,
859,
36905,
6689,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
2109,
84,
262,
3056,
3649,
21,
19,
198,
197,
1903,
11491,
353,
8470,
808,
1600,
35,
1117,
198,
197,
59403,
197,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestError_Envelope(t *testing.T) {
var herr Error
// happy path: transaction_failed with the appropriate extra fields
herr.Problem.Type = "transaction_failed"
herr.Problem.Extras = make(map[string]interface{})
herr.Problem.Extras["envelope_xdr"] = `AAAAADSMMRmQGDH6EJzkgi/7PoKhphMHyNGQgDp2tlS/dhGXAAAAZAAT3TUAAAAwAAAAAAAAAAAAAAABAAAAAAAAAAMAAAABSU5SAAAAAAA0jDEZkBgx+hCc5IIv+z6CoaYTB8jRkIA6drZUv3YRlwAAAAFVU0QAAAAAADSMMRmQGDH6EJzkgi/7PoKhphMHyNGQgDp2tlS/dhGXAAAAAAX14QAAAAAKAAAAAQAAAAAAAAAAAAAAAAAAAAG/dhGXAAAAQLuStfImg0OeeGAQmvLkJSZ1MPSkCzCYNbGqX5oYNuuOqZ5SmWhEsC7uOD9ha4V7KengiwNlc0oMNqBVo22S7gk=`
_, err := herr.Envelope()
assert.NoError(t, err)
// sad path: missing envelope_xdr extra
herr.Problem.Extras = make(map[string]interface{})
_, err = herr.Envelope()
assert.Equal(t, ErrEnvelopeNotPopulated, err)
// sad path: unparseable envelope_xdr extra
herr.Problem.Extras = make(map[string]interface{})
herr.Problem.Extras["envelope_xdr"] = "AAAAADSMMRmQGDH6EJzkgi"
_, err = herr.Envelope()
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "xdr decode")
}
} | explode_data.jsonl/12140 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 507
} | [
2830,
3393,
1454,
62,
62712,
1155,
353,
8840,
836,
8,
341,
2405,
54739,
4600,
271,
197,
322,
6247,
1815,
25,
7745,
35060,
448,
279,
8311,
4960,
5043,
198,
9598,
615,
7763,
10121,
10184,
284,
330,
13528,
35060,
698,
9598,
615,
7763,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMultiClose(t *testing.T) {
ps := New(2)
defer ps.Shutdown()
ch := ps.Sub("t1", "t2")
ps.Pub("hi", "t1")
ps.Close("t1")
ps.Pub("hello", "t2")
ps.Close("t2")
checkContents(t, ch, []string{"hi", "hello"})
} | explode_data.jsonl/44262 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
20358,
7925,
1155,
353,
8840,
836,
8,
341,
35009,
1669,
1532,
7,
17,
340,
16867,
4726,
10849,
18452,
2822,
23049,
1669,
4726,
12391,
445,
83,
16,
497,
330,
83,
17,
5130,
35009,
1069,
392,
445,
6023,
497,
330,
83,
16,
113... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReader(t *testing.T) {
source := &dataSource{}
reader := NewReader(source, time.Second, time.Millisecond*50)
start := time.Now()
data := make([]byte, 100)
count, err := reader.Read(data)
dur := time.Since(start)
if err != nil {
t.Error("read failed: ", err)
}
if dur < 100*time.Millisecond || dur > 400*time.Millisecond {
t.Error("expected dur to be around 150ms: ", dur)
}
if count != 10 {
t.Error("expected count to be 10: ", count)
}
data = data[0:count]
expData := []byte{0, 1, 1, 1, 1, 1, 1, 1, 1, 1}
if !reflect.DeepEqual(data, expData) {
t.Error("expected: ", expData)
t.Error("got : ", data)
}
} | explode_data.jsonl/49962 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
5062,
1155,
353,
8840,
836,
8,
341,
47418,
1669,
609,
64860,
16094,
61477,
1669,
1532,
5062,
12437,
11,
882,
32435,
11,
882,
71482,
9,
20,
15,
692,
21375,
1669,
882,
13244,
741,
8924,
1669,
1281,
10556,
3782,
11,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func Test_new_encoder(t *testing.T) {
should := require.New(t)
buf1 := &bytes.Buffer{}
encoder1 := json.NewEncoder(buf1)
encoder1.SetEscapeHTML(false)
encoder1.Encode([]int{1})
should.Equal("[1]\n", buf1.String())
buf2 := &bytes.Buffer{}
encoder2 := jsoniter.NewEncoder(buf2)
encoder2.SetEscapeHTML(false)
encoder2.Encode([]int{1})
should.Equal("[1]\n", buf2.String())
} | explode_data.jsonl/3081 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
5921,
39068,
1155,
353,
8840,
836,
8,
341,
197,
5445,
1669,
1373,
7121,
1155,
340,
26398,
16,
1669,
609,
9651,
22622,
16094,
197,
27008,
16,
1669,
2951,
7121,
19921,
10731,
16,
340,
197,
27008,
16,
4202,
48124,
5835,
3576,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKeyPath(t *testing.T) {
dir := newTempDir(t)
defer os.RemoveAll(dir)
_, keyPath := newCaDirectory(t, dir, &defaultCertMaterial, &defaultKeyMaterial)
ca, err := cert.Load(keyPath)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
actualCertMaterial := string(ca.Certificate)
if actualCertMaterial != defaultCertMaterial {
t.Errorf("expected '%v' got '%v'", defaultCertMaterial, actualCertMaterial)
}
actualKeyMaterial := string(ca.PrivateKey)
if actualKeyMaterial != defaultKeyMaterial {
t.Errorf("expected '%v' got '%v'", defaultKeyMaterial, actualKeyMaterial)
}
} | explode_data.jsonl/6228 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
1592,
1820,
1155,
353,
8840,
836,
8,
341,
48532,
1669,
501,
12151,
6184,
1155,
340,
16867,
2643,
84427,
14161,
340,
197,
6878,
1376,
1820,
1669,
501,
22571,
9310,
1155,
11,
5419,
11,
609,
2258,
36934,
13415,
11,
609,
2258,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestValueAtPathSuccess(t *testing.T) {
var testCases = []struct {
expect []interface{}
data interface{}
path string
}{
{[]interface{}{"initial"}, data, "C"},
{[]interface{}{"value1"}, data, "A[0].C"},
{[]interface{}{"value2"}, data, "A[1].C"},
{[]interface{}{"value3"}, data, "A[2].C"},
{[]interface{}{"value3"}, data, "a[2].c"},
{[]interface{}{"value3"}, data, "A[-1].C"},
{[]interface{}{"value1", "value2", "value3"}, data, "A[].C"},
{[]interface{}{"terminal"}, data, "B . B . C"},
{[]interface{}{"initial"}, data, "A.D.X || C"},
{[]interface{}{"initial"}, data, "A[0].B || C"},
{[]interface{}{
Struct{A: []Struct{{C: "1"}, {C: "1"}, {C: "1"}, {C: "1"}, {C: "1"}}},
Struct{A: []Struct{{C: "2"}, {C: "2"}, {C: "2"}, {C: "2"}, {C: "2"}}},
}, data2, "A"},
}
for i, c := range testCases {
v, err := awsutil.ValuesAtPath(c.data, c.path)
assert.NoError(t, err, "case %d, expected no error, %s", i, c.path)
assert.Equal(t, c.expect, v, "case %d, %s", i, c.path)
}
} | explode_data.jsonl/26250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 473
} | [
2830,
3393,
1130,
86422,
7188,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
37302,
284,
3056,
1235,
341,
197,
24952,
3056,
4970,
16094,
197,
8924,
256,
3749,
16094,
197,
26781,
256,
914,
198,
197,
59403,
197,
197,
90,
1294,
4970,
6257,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestVariables_AddProjectName(t *testing.T) {
projectName := "project"
variables := NewVariables()
variables.AddProjectName(projectName)
assert.Equal(t,projectName, variables["project_name"])
} | explode_data.jsonl/66409 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
22678,
21346,
7849,
675,
1155,
353,
8840,
836,
8,
341,
262,
72516,
1669,
330,
4987,
698,
262,
7332,
1669,
1532,
22678,
741,
262,
7332,
1904,
7849,
675,
21168,
675,
340,
262,
2060,
12808,
1155,
11,
4987,
675,
11,
7332,
1183... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCreateDefaultConfig(t *testing.T) {
cfg := createDefaultConfig().(*Config)
assert.NotNil(t, cfg, "failed to create default config")
assert.NoError(t, configcheck.ValidateConfig(cfg))
assert.Equal(t, []string{defaultBroker}, cfg.Brokers)
assert.Equal(t, defaultTopic, cfg.Topic)
assert.Equal(t, defaultGroupID, cfg.GroupID)
assert.Equal(t, defaultClientID, cfg.ClientID)
} | explode_data.jsonl/70852 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 141
} | [
2830,
3393,
4021,
3675,
2648,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
1855,
3675,
2648,
1005,
4071,
2648,
340,
6948,
93882,
1155,
11,
13286,
11,
330,
16091,
311,
1855,
1638,
2193,
1138,
6948,
35699,
1155,
11,
2193,
2028,
47667,
2648,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStaticDatasetQueryHappy(t *testing.T) {
Convey("Given a correct response from the /graphql endpoint", t, func() {
testCtx := context.Background()
mockHttpClient := &dphttp.ClienterMock{}
mockGQLClient := &mock.GraphQLClientMock{
QueryFunc: func(ctx context.Context, query interface{}, vars map[string]interface{}) error {
return nil
},
}
cantabularClient := cantabular.NewClient(
cantabular.Config{
Host: "cantabular.host",
ExtApiHost: "cantabular.ext.host",
},
mockHttpClient,
mockGQLClient,
)
Convey("When the StaticDatasetQuery method is called", func() {
req := cantabular.StaticDatasetQueryRequest{}
_, err := cantabularClient.StaticDatasetQuery(testCtx, req)
Convey("No error should be returned", func() {
So(err, ShouldBeNil)
})
})
})
} | explode_data.jsonl/8455 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 335
} | [
2830,
3393,
11690,
33363,
2859,
32847,
1155,
353,
8840,
836,
8,
1476,
93070,
5617,
445,
22043,
264,
4396,
2033,
504,
279,
608,
38294,
14887,
497,
259,
11,
2915,
368,
341,
197,
18185,
23684,
1669,
2266,
19047,
2822,
197,
77333,
26316,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGyLinksFailureOCStoFEG(t *testing.T) {
fmt.Println("\nRunning TestGyLinksFailureOCStoFEG...")
tr, ruleManager, ue := ocsCreditExhaustionTestSetup(t)
defer func() {
// Clear hss, ocs, and pcrf
assert.NoError(t, clearOCSMockDriver())
assert.NoError(t, ruleManager.RemoveInstalledRules())
assert.NoError(t, tr.CleanUp())
}()
initRequest := protos.NewGyCCRequest(ue.GetImsi(), protos.CCRequestType_INITIAL)
initAnswer := protos.NewGyCCAnswer(0).SetLinkFailure(true)
initExpectation := protos.NewGyCreditControlExpectation().Expect(initRequest).Return(initAnswer)
expectations := []*protos.GyCreditControlExpectation{initExpectation}
// On unexpected requests, just return the default update answer
assert.NoError(t, setOCSExpectations(expectations, nil))
tr.AuthenticateAndAssertFail(ue.Imsi)
resultByIndex, errByIndex, err := getOCSAssertExpectationsResult()
assert.NoError(t, err)
assert.Empty(t, errByIndex)
expectedResult := []*protos.ExpectationResult{{ExpectationIndex: 0, ExpectationMet: true}}
assert.ElementsMatch(t, expectedResult, resultByIndex)
// Since CCA-I was never received, there should be no rules installed
recordsBySubID, err := tr.GetPolicyUsage()
assert.NoError(t, err)
assert.Empty(t, recordsBySubID["IMSI"+ue.Imsi])
} | explode_data.jsonl/18982 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 452
} | [
2830,
3393,
38,
88,
24089,
17507,
7612,
623,
78,
37,
9376,
1155,
353,
8840,
836,
8,
341,
11009,
12419,
4921,
77,
18990,
3393,
38,
88,
24089,
17507,
7612,
623,
78,
37,
9376,
1112,
5130,
25583,
11,
5912,
2043,
11,
60098,
1669,
297,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPostDominators(t *testing.T) {
c := testConfig(t)
fun := Fun(c, "entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("p", OpConstBool, TypeBool, 1, nil),
If("p", "a", "c")),
Bloc("a",
If("p", "b", "c")),
Bloc("b",
Goto("c")),
Bloc("c",
If("p", "b", "exit")),
Bloc("exit",
Exit("mem")))
doms := map[string]string{"entry": "c",
"a": "c",
"b": "c",
"c": "exit",
}
CheckFunc(fun.f)
verifyDominators(t, fun, postDominators, doms)
} | explode_data.jsonl/77587 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
4133,
71541,
2973,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1273,
2648,
1155,
340,
90126,
1669,
16071,
1337,
11,
330,
4085,
756,
197,
12791,
1074,
445,
4085,
756,
298,
197,
2208,
84,
445,
10536,
497,
10672,
3803,
18816,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCheckoutRevisionCanGetNonstandardRefs(t *testing.T) {
rootPath := t.TempDir()
sourceRepoPath, err := ioutil.TempDir(rootPath, "")
require.NoError(t, err)
// Create a repo such that one commit is on a non-standard ref _and nowhere else_. This is meant to simulate, for
// example, a GitHub ref for a pull into one repo from a fork of that repo.
runGit(t, sourceRepoPath, "init")
runGit(t, sourceRepoPath, "checkout", "-b", "main") // make sure there's a main branch to switch back to
runGit(t, sourceRepoPath, "commit", "-m", "empty", "--allow-empty")
runGit(t, sourceRepoPath, "checkout", "-b", "branch")
runGit(t, sourceRepoPath, "commit", "-m", "empty", "--allow-empty")
sha := runGit(t, sourceRepoPath, "rev-parse", "HEAD")
runGit(t, sourceRepoPath, "update-ref", "refs/pull/123/head", strings.TrimSuffix(sha, "\n"))
runGit(t, sourceRepoPath, "checkout", "main")
runGit(t, sourceRepoPath, "branch", "-D", "branch")
destRepoPath, err := ioutil.TempDir(rootPath, "")
require.NoError(t, err)
gitClient, err := git.NewClientExt("file://"+sourceRepoPath, destRepoPath, &git.NopCreds{}, true, false, "")
require.NoError(t, err)
pullSha, err := gitClient.LsRemote("refs/pull/123/head")
require.NoError(t, err)
err = checkoutRevision(gitClient, "does-not-exist", false)
assert.Error(t, err)
err = checkoutRevision(gitClient, pullSha, false)
assert.NoError(t, err)
} | explode_data.jsonl/5709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 532
} | [
2830,
3393,
55145,
33602,
6713,
1949,
8121,
20270,
82807,
1155,
353,
8840,
836,
8,
341,
33698,
1820,
1669,
259,
65009,
6184,
2822,
47418,
25243,
1820,
11,
1848,
1669,
43144,
65009,
6184,
9206,
1820,
11,
14676,
17957,
35699,
1155,
11,
1848... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWithEnableCompression(t *testing.T) {
type T = transport
type args struct {
enable bool
}
type want struct {
obj *T
err error
}
type test struct {
name string
args args
want want
checkFunc func(want, *T, error) error
beforeFunc func(args)
afterFunc func(args)
}
defaultCheckFunc := func(w want, obj *T, err error) error {
if !errors.Is(err, w.err) {
return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err)
}
if diff := comparator.Diff(obj, w.obj, transportComparator...); diff != "" {
return errors.New(diff)
}
return nil
}
tests := []test{
{
name: "set enable success",
args: args{
enable: true,
},
want: want{
obj: &T{
Transport: &http.Transport{
DisableCompression: false,
},
},
},
},
{
name: "set disable success",
args: args{
enable: false,
},
want: want{
obj: &T{
Transport: &http.Transport{
DisableCompression: true,
},
},
},
},
}
for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(tt, goleakIgnoreOptions...)
if test.beforeFunc != nil {
test.beforeFunc(test.args)
}
if test.afterFunc != nil {
defer test.afterFunc(test.args)
}
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
got := WithEnableCompression(test.args.enable)
obj := &T{
Transport: &http.Transport{},
}
if err := test.checkFunc(test.want, obj, got(obj)); err != nil {
tt.Errorf("error = %v", err)
}
})
}
} | explode_data.jsonl/57545 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 745
} | [
2830,
3393,
2354,
11084,
81411,
1155,
353,
8840,
836,
8,
341,
13158,
350,
284,
7557,
198,
13158,
2827,
2036,
341,
197,
197,
12552,
1807,
198,
197,
532,
13158,
1366,
2036,
341,
197,
22671,
353,
51,
198,
197,
9859,
1465,
198,
197,
532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRollupQuantileOverTime(t *testing.T) {
f := func(phi, vExpected float64) {
t.Helper()
phis := []*timeseries{{
Values: []float64{phi},
Timestamps: []int64{123},
}}
var me metricsql.MetricExpr
args := []interface{}{phis, &metricsql.RollupExpr{Expr: &me}}
testRollupFunc(t, "quantile_over_time", args, &me, vExpected)
}
f(-123, 12)
f(-0.5, 12)
f(0, 12)
f(0.1, 21)
f(0.5, 34)
f(0.9, 99)
f(1, 123)
f(234, 123)
} | explode_data.jsonl/23114 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
32355,
454,
44220,
457,
1918,
1462,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
2915,
48230,
11,
348,
18896,
2224,
21,
19,
8,
341,
197,
3244,
69282,
741,
197,
197,
36789,
1669,
29838,
15136,
4699,
90,
515,
298,
197,
6227,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateSSH(t *testing.T) {
rg := rand.New(rand.NewSource(42))
translator := &i18n.Translator{
Locale: nil,
}
privateKey, publicKey, err := CreateSSH(rg, translator)
if err != nil {
t.Fatalf("failed to generate SSH: %s", err)
}
pemBlock := &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(privateKey),
}
pemBuffer := bytes.Buffer{}
pem.Encode(&pemBuffer, pemBlock)
if !strings.HasPrefix(pemBuffer.String(), "-----BEGIN RSA PRIVATE KEY-----") {
t.Fatalf("Private Key did not start with expected header")
}
if privateKey.N.BitLen() != SSHKeySize {
t.Fatalf("Private Key was of length %d but %d was expected", privateKey.N.BitLen(), SSHKeySize)
}
if err := privateKey.Validate(); err != nil {
t.Fatalf("Private Key failed validation: %v", err)
}
if !strings.HasPrefix(publicKey, "ssh-rsa ") {
t.Fatalf("Public Key did not start with expected header")
}
} | explode_data.jsonl/7027 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 352
} | [
2830,
3393,
4021,
62419,
1155,
353,
8840,
836,
8,
341,
197,
1984,
1669,
10382,
7121,
37595,
7121,
3608,
7,
19,
17,
4390,
197,
44357,
1669,
609,
72,
16,
23,
77,
11815,
21829,
515,
197,
197,
19231,
25,
2092,
345,
197,
630,
2455,
1592,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestForStringLabelDefault(t *testing.T) {
var out bytes.Buffer
var in bytes.Buffer
in.Write([]byte("\n")) // [ENTER]
// No lablel but a default
_ = prompt.ForString("", "Alice",
prompt.WithInput(&in), prompt.WithOutput(&out))
if out.String() != "(Alice): " {
t.Fatalf("expected '(Alice): ', got '%v'\n", out.String())
}
out.Reset()
in.Reset()
in.Write([]byte("\n")) // [ENTER]
// Label with default
_ = prompt.ForString("Name", "Alice",
prompt.WithInput(&in), prompt.WithOutput(&out))
if out.String() != "Name (Alice): " {
t.Fatalf("expected 'Name (Alice): ', got '%v'\n", out.String())
}
} | explode_data.jsonl/6611 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
2461,
703,
2476,
3675,
1155,
353,
8840,
836,
8,
341,
2405,
700,
5820,
22622,
198,
2405,
304,
5820,
22622,
198,
17430,
4073,
10556,
3782,
4921,
77,
2761,
442,
508,
12847,
2533,
197,
322,
2308,
326,
480,
75,
714,
264,
1638,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCollectionService_Create(t *testing.T) {
client, mux := setup(t)
blob, err := readFileContents("../testdata/collection/collection.json")
require.NoError(t, err)
mux.HandleFunc("/api/v1/collections/create_collection", func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, http.MethodPost, r.Method)
form := url.Values{}
form.Set("title", "Test Title")
form.Set("sr_fullname", "t5_2uquw1")
form.Set("display_layout", "TIMELINE")
err := r.ParseForm()
require.NoError(t, err)
require.Equal(t, form, r.PostForm)
fmt.Fprint(w, blob)
})
_, _, err = client.Collection.Create(ctx, nil)
require.EqualError(t, err, "*CollectionCreateRequest: cannot be nil")
collection, _, err := client.Collection.Create(ctx, &CollectionCreateRequest{
Title: "Test Title",
SubredditID: "t5_2uquw1",
Layout: "TIMELINE",
})
require.NoError(t, err)
require.Equal(t, expectedCollection, collection)
} | explode_data.jsonl/12628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 370
} | [
2830,
3393,
6482,
1860,
34325,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
1669,
6505,
1155,
692,
2233,
1684,
11,
1848,
1669,
61732,
14803,
17409,
92425,
2899,
1908,
2899,
1908,
4323,
1138,
17957,
35699,
1155,
11,
1848,
692,
2109,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTriggerInitializeConditions(t *testing.T) {
tests := []struct {
name string
ts *TriggerStatus
want *TriggerStatus
}{{
name: "empty",
ts: &TriggerStatus{},
want: &TriggerStatus{
Status: duckv1beta1.Status{
Conditions: []apis.Condition{{
Type: TriggerConditionBroker,
Status: corev1.ConditionUnknown,
}, {
Type: TriggerConditionReady,
Status: corev1.ConditionUnknown,
}, {
Type: TriggerConditionSubscribed,
Status: corev1.ConditionUnknown,
}},
},
},
}, {
name: "one false",
ts: &TriggerStatus{
Status: duckv1beta1.Status{
Conditions: []apis.Condition{{
Type: TriggerConditionBroker,
Status: corev1.ConditionFalse,
}},
},
},
want: &TriggerStatus{
Status: duckv1beta1.Status{
Conditions: []apis.Condition{{
Type: TriggerConditionBroker,
Status: corev1.ConditionFalse,
}, {
Type: TriggerConditionReady,
Status: corev1.ConditionUnknown,
}, {
Type: TriggerConditionSubscribed,
Status: corev1.ConditionUnknown,
}},
},
},
}, {
name: "one true",
ts: &TriggerStatus{
Status: duckv1beta1.Status{
Conditions: []apis.Condition{{
Type: TriggerConditionSubscribed,
Status: corev1.ConditionTrue,
}},
},
},
want: &TriggerStatus{
Status: duckv1beta1.Status{
Conditions: []apis.Condition{{
Type: TriggerConditionBroker,
Status: corev1.ConditionUnknown,
}, {
Type: TriggerConditionReady,
Status: corev1.ConditionUnknown,
}, {
Type: TriggerConditionSubscribed,
Status: corev1.ConditionTrue,
}},
},
},
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
test.ts.InitializeConditions()
if diff := cmp.Diff(test.want, test.ts, ignoreAllButTypeAndStatus); diff != "" {
t.Errorf("unexpected conditions (-want, +got) = %v", diff)
}
})
}
} | explode_data.jsonl/54994 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 843
} | [
2830,
3393,
17939,
9928,
35435,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
57441,
256,
353,
17939,
2522,
198,
197,
50780,
353,
17939,
2522,
198,
197,
15170,
515,
197,
11609,
25,
330,
3194,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestParseKubectlError(t *testing.T) {
tests := []struct {
description string
details string
err error
expectedAe proto.ActionableErr
}{
{
description: "rollout status connection error",
err: errors.New("Unable to connect to the server"),
expectedAe: proto.ActionableErr{
ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_CONNECTION_ERR,
Message: MsgKubectlConnection,
},
},
{
description: "rollout status kubectl command killed",
err: errors.New("signal: killed"),
expectedAe: proto.ActionableErr{
ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_PID_KILLED,
Message: msgKubectlKilled,
},
},
{
description: "rollout status random error",
err: errors.New("deployment test not found"),
expectedAe: proto.ActionableErr{
ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN,
Message: "deployment test not found",
},
},
{
description: "rollout status nil error",
details: "successfully rolled out",
expectedAe: proto.ActionableErr{
ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS,
Message: "successfully rolled out",
},
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
ae := parseKubectlRolloutError(test.details, test.err)
t.CheckDeepEqual(test.expectedAe, ae)
})
}
} | explode_data.jsonl/81096 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 573
} | [
2830,
3393,
14463,
42,
53380,
1454,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
2698,
2237,
257,
914,
198,
197,
9859,
260,
1465,
198,
197,
42400,
32,
68,
220,
18433,
11360,
480,
7747,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTimeSinceScrub(t *testing.T) {
t.Parallel()
require.Greater(
t,
timeSinceScrub(sampleStatusNormalOutput),
float64(6000),
)
require.Equal(
t,
float64(0),
timeSinceScrub(sampleStatusUnscrubbedOutput),
)
} | explode_data.jsonl/18992 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
1462,
12549,
3326,
59430,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
17957,
1224,
28362,
1006,
197,
3244,
345,
197,
21957,
12549,
3326,
59430,
32968,
2522,
12206,
5097,
1326,
197,
8139,
21,
19,
7,
21,
15,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClientDefaultUserAgent(t *testing.T) {
t.Parallel()
ln := fasthttputil.NewInmemoryListener()
userAgentSeen := ""
s := &Server{
Handler: func(ctx *RequestCtx) {
userAgentSeen = string(ctx.UserAgent())
},
}
go s.Serve(ln) //nolint:errcheck
c := &Client{
Dial: func(addr string) (net.Conn, error) {
return ln.Dial()
},
}
req := AcquireRequest()
res := AcquireResponse()
req.SetRequestURI("http://example.com")
err := c.Do(req, res)
if err != nil {
t.Fatal(err)
}
if userAgentSeen != string(defaultUserAgent) {
t.Fatalf("User-Agent defers %q != %q", userAgentSeen, defaultUserAgent)
}
} | explode_data.jsonl/79344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
2959,
3675,
1474,
16810,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
2261,
1669,
4937,
96336,
628,
321,
7121,
641,
17269,
2743,
2822,
19060,
16810,
85675,
1669,
8389,
1903,
1669,
609,
5475,
515,
197,
197,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCannotRunProcessOnRunningPipeline(t *testing.T) {
p := pipeline.New(
pipeline.Node(&NoOpProcessor{}),
)
go p.Process(&SimpleReader{})
defer p.Shutdown()
time.Sleep(100 * time.Millisecond)
assert.Panics(t, func() {
p.Process(&SimpleReader{})
})
} | explode_data.jsonl/64694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
17444,
6727,
7423,
1925,
18990,
34656,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
15301,
7121,
1006,
197,
3223,
8790,
21714,
2099,
2753,
7125,
22946,
6257,
1326,
197,
692,
30680,
281,
29012,
2099,
16374,
5062,
37790,
16867,
281... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_statementsNextView(t *testing.T) {
testcases := []struct {
current string
want string
}{
{current: "statements_timings", want: "statements_general"},
{current: "statements_general", want: "statements_io"},
{current: "statements_io", want: "statements_temp"},
{current: "statements_temp", want: "statements_local"},
{current: "statements_local", want: "statements_wal"},
{current: "statements_wal", want: "statements_timings"},
{current: "unknown", want: "statements_timings"},
}
for _, tc := range testcases {
assert.Equal(t, tc.want, statementsNextView(tc.current))
}
} | explode_data.jsonl/69230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
16271,
3723,
5847,
851,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
20121,
914,
198,
197,
50780,
262,
914,
198,
197,
59403,
197,
197,
90,
3231,
25,
330,
94587,
29087,
819,
497,
1366,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetTrades(t *testing.T) {
t.Parallel()
_, err := b.GetTrades("BTC", "AUD", nil)
if err != nil {
t.Error("Test failed - GetTrades() error", err)
}
val := url.Values{}
val.Set("since", "0")
_, err = b.GetTrades("BTC", "AUD", val)
if err != nil {
t.Error("Test failed - GetTrades() error", err)
}
} | explode_data.jsonl/48989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 136
} | [
2830,
3393,
1949,
1282,
3452,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
293,
2234,
1282,
3452,
445,
59118,
497,
330,
61278,
497,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
445,
2271,
4641... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestStartStandAlone(t *testing.T) {
home, err := ioutil.TempDir("", "mock-sdk-cmd")
require.Nil(t, err)
defer func() {
os.RemoveAll(home)
}()
viper.Set(cli.HomeFlag, home)
defer setupClientHome(t)()
logger := log.NewNopLogger()
cfg, err := tcmd.ParseConfig()
require.Nil(t, err)
ctx := server.NewContext(cfg, logger)
cdc := app.MakeLatestCodec()
initCmd := InitCmd(ctx, cdc)
require.NoError(t, initCmd.RunE(nil, []string{"hsnode-test"}))
app, err := mock.NewApp(home, logger)
require.Nil(t, err)
svrAddr, _, err := server.FreeTCPAddr()
require.Nil(t, err)
svr, err := abciServer.NewServer(svrAddr, "socket", app)
require.Nil(t, err, "error creating listener")
svr.SetLogger(logger.With("module", "abci-server"))
svr.Start()
timer := time.NewTimer(time.Duration(2) * time.Second)
select {
case <-timer.C:
svr.Stop()
}
} | explode_data.jsonl/17821 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
3479,
48733,
2101,
603,
1155,
353,
8840,
836,
8,
341,
197,
5117,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
16712,
35478,
1786,
2277,
1138,
17957,
59678,
1155,
11,
1848,
340,
16867,
2915,
368,
341,
197,
25078,
84427,
63... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWorkflowTemplateServer_ListClusterWorkflowTemplates(t *testing.T) {
server, ctx := getClusterWorkflowTemplateServer()
cwftReq := clusterwftmplpkg.ClusterWorkflowTemplateListRequest{}
cwftRsp, err := server.ListClusterWorkflowTemplates(ctx, &cwftReq)
if assert.NoError(t, err) {
assert.Len(t, cwftRsp.Items, 2)
for _, item := range cwftRsp.Items {
assert.Contains(t, item.Labels, common.LabelKeyControllerInstanceID)
}
}
} | explode_data.jsonl/48138 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
62768,
7275,
5475,
27104,
28678,
62768,
51195,
1155,
353,
8840,
836,
8,
341,
41057,
11,
5635,
1669,
633,
28678,
62768,
7275,
5475,
741,
1444,
86,
723,
27234,
1669,
10652,
86,
723,
54010,
30069,
72883,
62768,
7275,
852,
1900,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestProdCons(t *testing.T) {
t.Parallel()
t.Run("nothing provided ends", func(t *testing.T) {
t.Parallel()
err := (&prodcons.Runner{}).Run()
assert.NoError(t, err)
})
t.Run("the consumer receives exactly one time", func(t *testing.T) {
t.Parallel()
var producerCount = 1000
produced := set.OfStrings()
runner := prodcons.Runner{}
for i := 0; i < producerCount; i++ {
producedStr := strings.RandOfSize(5)
produced.Put(producedStr)
runner.Producer(func() (interface{}, error) { return producedStr, nil })
}
consumed := set.OfStrings()
consumerCalledCount := 0
err := runner.Consumer(func(data interface{}) error {
consumerCalledCount++
s, ok := data.(string)
if !ok {
return errors.New("unable to cast to string")
}
consumed.Put(s)
return nil
}).Run()
assert.NoError(t, err)
assert.Equal(t, producerCount, consumerCalledCount)
assert.True(t, consumed.Equals(produced))
})
t.Run("error is returned", func(t *testing.T) {
t.Parallel()
runner := prodcons.Runner{}
err := runner.
Consumer(func(i interface{}) error { return nil }).
Producer(func() (interface{}, error) { return 0, errors.New("err") }).
Run()
assert.Error(t, err)
var producerCount = 1000
runner = prodcons.Runner{}
for i := 0; i < producerCount; i++ {
runner.Producer(func() (interface{}, error) { return 0, nil })
}
runner.Producer(func() (interface{}, error) { return -1, errors.New("error") })
err = runner.Consumer(func(interface{}) error { return nil }).Run()
assert.Error(t, err)
runner = prodcons.Runner{}
err = runner.
Consumer(func(i interface{}) error { return errors.New("consumer failed") }).
Producer(func() (interface{}, error) { return 1, nil }).
Run()
assert.Error(t, err)
})
t.Run("no producer doesn't block", func(t *testing.T) {
t.Parallel()
runner := prodcons.Runner{}
err := runner.Consumer(func(i interface{}) error { return nil }).Run()
assert.NoError(t, err)
})
} | explode_data.jsonl/75650 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 765
} | [
2830,
3393,
41279,
15220,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3244,
16708,
445,
41212,
3897,
10335,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3244,
41288,
7957,
741,
197,
9859,
1669,
15899,
19748,
6254,
16708,
1194... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddReadingError(t *testing.T) {
reset()
myMock := &dbMock.DBClient{}
myMock.On("AddReading", mock.Anything).Return("", fmt.Errorf("some error"))
dbClient = myMock
_, err := addReading(models.Reading{}, logger.NewMockClient())
if err == nil {
t.Errorf("Expected error adding reading")
}
} | explode_data.jsonl/48168 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
2212,
31899,
1454,
1155,
353,
8840,
836,
8,
341,
70343,
741,
13624,
11571,
1669,
609,
1999,
11571,
22537,
2959,
31483,
13624,
11571,
8071,
445,
2212,
31899,
497,
7860,
13311,
1596,
568,
5598,
19814,
8879,
13080,
445,
14689,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMakePortsAndBindings(t *testing.T) {
for desc, test := range map[string]struct {
pm []*runtimeapi.PortMapping
exposedPorts dockernat.PortSet
portmappings map[dockernat.Port][]dockernat.PortBinding
}{
"no port mapping": {
pm: nil,
exposedPorts: map[dockernat.Port]struct{}{},
portmappings: map[dockernat.Port][]dockernat.PortBinding{},
},
"tcp port mapping": {
pm: []*runtimeapi.PortMapping{
{
Protocol: runtimeapi.Protocol_TCP,
ContainerPort: 80,
HostPort: 80,
},
},
exposedPorts: map[dockernat.Port]struct{}{
"80/tcp": {},
},
portmappings: map[dockernat.Port][]dockernat.PortBinding{
"80/tcp": {
{
HostPort: "80",
},
},
},
},
"udp port mapping": {
pm: []*runtimeapi.PortMapping{
{
Protocol: runtimeapi.Protocol_UDP,
ContainerPort: 80,
HostPort: 80,
},
},
exposedPorts: map[dockernat.Port]struct{}{
"80/udp": {},
},
portmappings: map[dockernat.Port][]dockernat.PortBinding{
"80/udp": {
{
HostPort: "80",
},
},
},
},
"multiple port mappings": {
pm: []*runtimeapi.PortMapping{
{
Protocol: runtimeapi.Protocol_TCP,
ContainerPort: 80,
HostPort: 80,
},
{
Protocol: runtimeapi.Protocol_TCP,
ContainerPort: 80,
HostPort: 81,
},
},
exposedPorts: map[dockernat.Port]struct{}{
"80/tcp": {},
},
portmappings: map[dockernat.Port][]dockernat.PortBinding{
"80/tcp": {
{
HostPort: "80",
},
{
HostPort: "81",
},
},
},
},
} {
t.Logf("TestCase: %s", desc)
actualExposedPorts, actualPortMappings := makePortsAndBindings(test.pm)
assert.Equal(t, test.exposedPorts, actualExposedPorts)
assert.Equal(t, test.portmappings, actualPortMappings)
}
} | explode_data.jsonl/52788 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 992
} | [
2830,
3393,
8078,
68273,
3036,
52843,
1155,
353,
8840,
836,
8,
341,
2023,
6560,
11,
1273,
1669,
2088,
2415,
14032,
60,
1235,
341,
197,
86511,
1843,
29838,
22255,
2068,
43013,
6807,
198,
197,
8122,
3865,
68273,
27549,
932,
266,
43013,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSum(t *testing.T) {
t.Parallel()
s := []float64{}
val := Sum(s)
if val != 0 {
t.Errorf("Val not returned as default when slice length is zero")
}
s = []float64{3, 4, 1, 7, 5}
val = Sum(s)
if val != 20 {
t.Errorf("Wrong sum returned")
}
} | explode_data.jsonl/1243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
9190,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
1669,
3056,
3649,
21,
19,
16094,
19302,
1669,
8116,
1141,
340,
743,
1044,
961,
220,
15,
341,
197,
3244,
13080,
445,
2208,
537,
5927,
438,
1638,
979,
15983,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestUpdateIssueValueErrs(t *testing.T) {
cucm, iucm, lucm, pucm, m := prepareMocksAndRUC()
tests := []struct {
body *strings.Reader
err error
}{
{
strings.NewReader("title=&description=test-description&status=1&labels=test1,test2,test3"),
errors.New("title not provided"),
},
{
strings.NewReader("title=test-title&description=&status=1&labels=test1,test2,test3"),
errors.New("description not provided"),
},
{
strings.NewReader("title=test-title&description=test-description&status=test&labels=test1,test2,test3"),
fmt.Errorf("strconv.Atoi: parsing \"%s\": invalid syntax", "test"),
},
}
for _, ts := range tests {
c, _ := prepareHTTP(echo.POST, "/api/issues/:id", ts.body)
c.SetParamNames("id")
c.SetParamValues("1")
err := m.UpdateIssue(c)
assert.NotNil(t, err)
assert.Equal(t, ts.err.Error(), err.Error())
checkAssertions(t, cucm, iucm, lucm, pucm)
}
} | explode_data.jsonl/60163 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 381
} | [
2830,
3393,
4289,
42006,
1130,
7747,
82,
1155,
353,
8840,
836,
8,
341,
1444,
1754,
76,
11,
600,
1754,
76,
11,
25927,
76,
11,
281,
1754,
76,
11,
296,
1669,
10549,
72577,
3036,
49,
5459,
2822,
78216,
1669,
3056,
1235,
341,
197,
35402,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetContainerHealth(t *testing.T) {
assert := asrt.New(t)
client := GetDockerClient()
labels := map[string]string{
"com.ddev.site-name": testContainerName,
}
container, err := FindContainerByLabels(labels)
require.NoError(t, err)
require.NotNil(t, container)
err = client.StopContainer(container.ID, 10)
assert.NoError(err)
status, _ := GetContainerHealth(container)
assert.Equal(status, "unhealthy")
err = client.StartContainer(container.ID, nil)
assert.NoError(err)
healthDetail, err := ContainerWait(30, labels)
assert.NoError(err)
assert.Equal("phpstatus: OK /var/www/html: OK mailhog: OK ", healthDetail)
status, healthDetail = GetContainerHealth(container)
assert.Equal("healthy", status)
assert.Equal("phpstatus: OK /var/www/html: OK mailhog: OK ", healthDetail)
} | explode_data.jsonl/41372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 282
} | [
2830,
3393,
1949,
4502,
14542,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
438,
3342,
7121,
1155,
340,
25291,
1669,
2126,
35,
13659,
2959,
2822,
95143,
1669,
2415,
14032,
30953,
515,
197,
197,
1,
874,
950,
3583,
22115,
11494,
788,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLeaderYield(t *testing.T) {
// Scenario: Spawn 2 peers and wait for the first one to be the leader
// There isn't any orderer present so the leader peer won't be able to
// connect to the orderer, and should relinquish its leadership after a while.
// Make sure the other peer declares itself as the leader soon after.
takeOverMaxTimeout := time.Minute
// It's enough to make single re-try
viper.Set("peer.deliveryclient.reconnectTotalTimeThreshold", time.Second*1)
// There is no ordering service available anyway, hence connection timeout
// could be shorter
viper.Set("peer.deliveryclient.connTimeout", time.Millisecond*100)
serviceConfig := &ServiceConfig{
UseLeaderElection: true,
OrgLeader: false,
ElectionStartupGracePeriod: election.DefStartupGracePeriod,
// Since we ensuring gossip has stable membership, there is no need for
// leader election to wait for stabilization
ElectionMembershipSampleInterval: time.Millisecond * 100,
ElectionLeaderAliveThreshold: time.Second * 5,
// Test case has only two instance + making assertions only after membership view
// is stable, hence election duration could be shorter
ElectionLeaderElectionDuration: time.Millisecond * 500,
}
n := 2
gossips := startPeers(t, serviceConfig, n, 0, 1)
defer stopPeers(gossips)
channelName := "channelA"
peerIndexes := []int{0, 1}
// Add peers to the channel
addPeersToChannel(t, n, channelName, gossips, peerIndexes)
// Prime the membership view of the peers
waitForFullMembershipOrFailNow(t, channelName, gossips, n, time.Second*30, time.Millisecond*100)
endpoint, socket := getAvailablePort(t)
socket.Close()
// Helper function that creates a gossipService instance
newGossipService := func(i int) *gossipServiceImpl {
gs := gossips[i].(*gossipGRPC).gossipServiceImpl
gs.deliveryFactory = &embeddingDeliveryServiceFactory{&deliveryFactoryImpl{}}
gossipServiceInstance = gs
gs.InitializeChannel(channelName, []string{endpoint}, Support{
Committer: &mockLedgerInfo{1},
Store: &transientStoreMock{},
})
return gs
}
// The first leader is determined by the peer with the lower PKIid (lower TCP port in this case).
// We set p0 to be the peer with the lower PKIid to ensure it'll be elected as leader before p1 and spare time.
pkiID0 := gossips[0].(*gossipGRPC).gossipServiceImpl.peerIdentity
pkiID1 := gossips[1].(*gossipGRPC).gossipServiceImpl.peerIdentity
var firstLeaderIdx, secondLeaderIdx int
if bytes.Compare(pkiID0, pkiID1) < 0 {
firstLeaderIdx = 0
secondLeaderIdx = 1
} else {
firstLeaderIdx = 1
secondLeaderIdx = 0
}
p0 := newGossipService(firstLeaderIdx)
p1 := newGossipService(secondLeaderIdx)
// Returns index of the leader or -1 if no leader elected
getLeader := func() int {
p0.lock.RLock()
p1.lock.RLock()
defer p0.lock.RUnlock()
defer p1.lock.RUnlock()
if p0.leaderElection[channelName].IsLeader() {
return 0
}
if p1.leaderElection[channelName].IsLeader() {
return 1
}
return -1
}
ds0 := p0.deliveryService[channelName].(*embeddingDeliveryService)
// Wait for p0 to connect to the ordering service
ds0.waitForDeliveryServiceActivation()
t.Log("p0 started its delivery service")
// Ensure it's a leader
assert.Equal(t, 0, getLeader())
// Wait for p0 to lose its leadership
ds0.waitForDeliveryServiceTermination()
t.Log("p0 stopped its delivery service")
// Ensure p0 is not a leader
assert.NotEqual(t, 0, getLeader())
// Wait for p1 to take over. It should take over before time reaches timeLimit
timeLimit := time.Now().Add(takeOverMaxTimeout)
for getLeader() != 1 && time.Now().Before(timeLimit) {
time.Sleep(100 * time.Millisecond)
}
if time.Now().After(timeLimit) && getLeader() != 1 {
util.PrintStackTrace()
t.Fatalf("p1 hasn't taken over leadership within %v: %d", takeOverMaxTimeout, getLeader())
}
t.Log("p1 has taken over leadership")
p0.chains[channelName].Stop()
p1.chains[channelName].Stop()
p0.deliveryService[channelName].Stop()
p1.deliveryService[channelName].Stop()
} | explode_data.jsonl/58840 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1380
} | [
2830,
3393,
52621,
56,
816,
1155,
353,
8840,
836,
8,
341,
197,
322,
58663,
25,
47361,
220,
17,
25029,
323,
3783,
369,
279,
1156,
825,
311,
387,
279,
7653,
198,
197,
322,
2619,
4436,
944,
894,
1973,
261,
3042,
773,
279,
7653,
14397,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTopologyModeFactory_computeResourcesForMinimumMode(t *testing.T) {
factory := NewTopologyModeFactory(nil)
testcases := map[string]struct {
nodeList *corev1.NodeList
err error
config map[nodeType]*nodeConfig
}{
"nodes-less-than-three": {
nodeList: &corev1.NodeList{
Items: []corev1.Node{
*newNode(16, 64),
*newNode(16, 32),
*newNode(8, 64),
},
},
config: nil,
err: errors.New("performance mode is not supported for nodes with different resources"),
},
"nodes-with-different-resources": {
nodeList: &corev1.NodeList{},
config: nil,
err: errors.New("nodes insufficient for performance mode"),
},
"normal-16c64g": {
nodeList: &corev1.NodeList{
Items: []corev1.Node{
*newNode(16, 64),
*newNode(16, 64),
*newNode(16, 64),
},
},
config: map[nodeType]*nodeConfig{
CN: {
replica: 3,
resource: factory.newResourceRequirements(4, 23957864448),
},
DN: {
replica: 3,
paxosReplica: 3,
resource: factory.newResourceRequirements(3, 15971909632),
},
GMS: {
replica: 1,
paxosReplica: 3,
resource: factory.newResourceRequirements(4, 8*GigaByte, 1, GigaByte),
},
},
err: nil,
},
"normal-32c256g": {
nodeList: &corev1.NodeList{
Items: []corev1.Node{
*newNode(32, 256),
*newNode(32, 256),
*newNode(32, 256),
},
},
config: map[nodeType]*nodeConfig{
CN: {
replica: 3,
resource: factory.newResourceRequirements(10, 101267275776),
},
DN: {
replica: 3,
paxosReplica: 3,
resource: factory.newResourceRequirements(7, 67511517184),
},
GMS: {
replica: 1,
paxosReplica: 3,
resource: factory.newResourceRequirements(4, 8*GigaByte, 1, GigaByte),
},
},
err: nil,
},
}
for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
config, err := factory.computeResourcesForPerformanceMode(tc.nodeList)
if err != nil {
if tc.err == nil {
t.Fatal("unexpected error", err)
}
if err.Error() != tc.err.Error() {
t.Fatal("unexpected error", err)
}
}
if !reflect.DeepEqual(config, tc.config) {
t.Fatal("unexpected config")
}
})
}
} | explode_data.jsonl/73838 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1114
} | [
2830,
3393,
60954,
3636,
4153,
57028,
11277,
2461,
28695,
3636,
1155,
353,
8840,
836,
8,
341,
1166,
2919,
1669,
1532,
60954,
3636,
4153,
27907,
340,
18185,
23910,
1669,
2415,
14032,
60,
1235,
341,
197,
20831,
852,
353,
98645,
16,
21714,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDomainMatchModel(t *testing.T) {
e, _ := NewEnforcer("examples/rbac_with_domain_pattern_model.conf", "examples/rbac_with_domain_pattern_policy.csv")
e.AddNamedDomainMatchingFunc("g", "keyMatch2", util.KeyMatch2)
testDomainEnforce(t, e, "alice", "domain1", "data1", "read", true)
testDomainEnforce(t, e, "alice", "domain1", "data1", "write", true)
testDomainEnforce(t, e, "alice", "domain1", "data2", "read", false)
testDomainEnforce(t, e, "alice", "domain1", "data2", "write", false)
testDomainEnforce(t, e, "alice", "domain2", "data2", "read", true)
testDomainEnforce(t, e, "alice", "domain2", "data2", "write", true)
testDomainEnforce(t, e, "bob", "domain2", "data1", "read", false)
testDomainEnforce(t, e, "bob", "domain2", "data1", "write", false)
testDomainEnforce(t, e, "bob", "domain2", "data2", "read", true)
testDomainEnforce(t, e, "bob", "domain2", "data2", "write", true)
} | explode_data.jsonl/57142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
13636,
8331,
1712,
1155,
353,
8840,
836,
8,
341,
7727,
11,
716,
1669,
1532,
1702,
82010,
445,
51668,
7382,
55877,
6615,
20111,
21260,
5047,
13937,
497,
330,
51668,
7382,
55877,
6615,
20111,
21260,
22773,
11219,
1138,
7727,
190... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNumericAssignTo(t *testing.T) {
type _int8 int8
var i8 int8
var i16 int16
var i32 int32
var i64 int64
var i int
var ui8 uint8
var ui16 uint16
var ui32 uint32
var ui64 uint64
var ui uint
var pi8 *int8
var _i8 _int8
var _pi8 *_int8
var f32 float32
var f64 float64
var pf32 *float32
var pf64 *float64
simpleTests := []struct {
src *shopspring.Numeric
dst interface{}
expected interface{}
}{
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &f32, expected: float32(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &f64, expected: float64(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "4.2"), Status: pgtype.Present}, dst: &f32, expected: float32(4.2)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "4.2"), Status: pgtype.Present}, dst: &f64, expected: float64(4.2)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &i16, expected: int16(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &i32, expected: int32(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &i64, expected: int64(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42000"), Status: pgtype.Present}, dst: &i64, expected: int64(42000)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &i, expected: int(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &ui8, expected: uint8(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &ui16, expected: uint16(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &ui32, expected: uint32(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &ui64, expected: uint64(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &ui, expected: uint(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &_i8, expected: _int8(42)},
{src: &shopspring.Numeric{Status: pgtype.Null}, dst: &pi8, expected: ((*int8)(nil))},
{src: &shopspring.Numeric{Status: pgtype.Null}, dst: &_pi8, expected: ((*_int8)(nil))},
}
for i, tt := range simpleTests {
err := tt.src.AssignTo(tt.dst)
if err != nil {
t.Errorf("%d: %v", i, err)
}
if dst := reflect.ValueOf(tt.dst).Elem().Interface(); dst != tt.expected {
t.Errorf("%d: expected %v to assign %v, but result was %v", i, tt.src, tt.expected, dst)
}
}
pointerAllocTests := []struct {
src *shopspring.Numeric
dst interface{}
expected interface{}
}{
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &pf32, expected: float32(42)},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "42"), Status: pgtype.Present}, dst: &pf64, expected: float64(42)},
}
for i, tt := range pointerAllocTests {
err := tt.src.AssignTo(tt.dst)
if err != nil {
t.Errorf("%d: %v", i, err)
}
if dst := reflect.ValueOf(tt.dst).Elem().Elem().Interface(); dst != tt.expected {
t.Errorf("%d: expected %v to assign %v, but result was %v", i, tt.src, tt.expected, dst)
}
}
errorTests := []struct {
src *shopspring.Numeric
dst interface{}
}{
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "150"), Status: pgtype.Present}, dst: &i8},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "40000"), Status: pgtype.Present}, dst: &i16},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "-1"), Status: pgtype.Present}, dst: &ui8},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "-1"), Status: pgtype.Present}, dst: &ui16},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "-1"), Status: pgtype.Present}, dst: &ui32},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "-1"), Status: pgtype.Present}, dst: &ui64},
{src: &shopspring.Numeric{Decimal: mustParseDecimal(t, "-1"), Status: pgtype.Present}, dst: &ui},
{src: &shopspring.Numeric{Status: pgtype.Null}, dst: &i32},
}
for i, tt := range errorTests {
err := tt.src.AssignTo(tt.dst)
if err == nil {
t.Errorf("%d: expected error but none was returned (%v -> %v)", i, tt.src, tt.dst)
}
}
} | explode_data.jsonl/39597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1891
} | [
2830,
3393,
36296,
28933,
1249,
1155,
353,
8840,
836,
8,
341,
13158,
716,
396,
23,
526,
23,
271,
2405,
600,
23,
526,
23,
198,
2405,
600,
16,
21,
526,
16,
21,
198,
2405,
600,
18,
17,
526,
18,
17,
198,
2405,
600,
21,
19,
526,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestVerCodeIsExpired(t *testing.T) {
code := VerificationCode{
Code: "12345678",
TestType: "confirmed",
ExpiresAt: time.Now().Add(time.Hour),
}
if got := code.IsExpired(); got {
t.Errorf("code says expired, when shouldn't be")
}
} | explode_data.jsonl/22973 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
10141,
2078,
3872,
54349,
1155,
353,
8840,
836,
8,
341,
43343,
1669,
55473,
2078,
515,
197,
90774,
25,
414,
330,
16,
17,
18,
19,
20,
21,
22,
23,
756,
197,
73866,
929,
25,
220,
330,
41028,
756,
197,
197,
65331,
1655,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCheckChaincodeVersion(t *testing.T) {
lscc := &SCC{}
validCCName := "ccname"
/*allowed versions*/
err := lscc.isValidChaincodeVersion(validCCName, "a_b")
require.NoError(t, err)
err = lscc.isValidChaincodeVersion(validCCName, "a.b")
require.NoError(t, err)
err = lscc.isValidChaincodeVersion(validCCName, "a+b")
require.NoError(t, err)
err = lscc.isValidChaincodeVersion(validCCName, "a-b")
require.NoError(t, err)
err = lscc.isValidChaincodeVersion(validCCName, "-ab")
require.NoError(t, err)
err = lscc.isValidChaincodeVersion(validCCName, "a.0")
require.NoError(t, err)
err = lscc.isValidChaincodeVersion(validCCName, "a_b.c+d-e")
require.NoError(t, err)
err = lscc.isValidChaincodeVersion(validCCName, "0")
require.NoError(t, err)
/*invalid versions*/
err = lscc.isValidChaincodeVersion(validCCName, "")
require.EqualError(t, err, "invalid chaincode version ''. Versions must not be empty and can only consist of alphanumerics, '_', '-', '+', and '.'")
err = lscc.isValidChaincodeVersion(validCCName, "$badversion")
require.EqualError(t, err, "invalid chaincode version '$badversion'. Versions must not be empty and can only consist of alphanumerics, '_', '-', '+', and '.'")
} | explode_data.jsonl/11804 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 458
} | [
2830,
3393,
3973,
18837,
1851,
5637,
1155,
353,
8840,
836,
8,
341,
197,
4730,
638,
1669,
609,
3540,
34,
31483,
56322,
3706,
675,
1669,
330,
638,
606,
698,
197,
1057,
20967,
10795,
3276,
9859,
1669,
19597,
638,
32161,
18837,
1851,
5637,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestImageTagError(t *testing.T) {
client := &Client{
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
}
err := client.ImageTag(context.Background(), "image_id", "repo:tag")
if err == nil || err.Error() != "Error response from daemon: Server error" {
t.Fatalf("expected a Server Error, got %v", err)
}
} | explode_data.jsonl/22949 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
1906,
5668,
1454,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
609,
2959,
515,
197,
25291,
25,
501,
11571,
2959,
6390,
11571,
19886,
66760,
11,
330,
5475,
1465,
30154,
197,
630,
9859,
1669,
2943,
7528,
5668,
5378,
19047,
1507,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetOwnedOrgsByUserID(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
orgs, err := GetOwnedOrgsByUserID(2)
assert.NoError(t, err)
if assert.Len(t, orgs, 1) {
assert.EqualValues(t, 3, orgs[0].ID)
}
orgs, err = GetOwnedOrgsByUserID(4)
assert.NoError(t, err)
assert.Len(t, orgs, 0)
} | explode_data.jsonl/71065 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
1949,
57641,
42437,
82,
1359,
36899,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
31166,
2271,
5988,
12367,
87625,
82,
11,
1848,
1669,
2126,
57641,
42437,
82,
1359,
36899,
7,
17,
340,
6948,
35699,
1155,
11,
1848,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestResources_AddLoadBalancer(t *testing.T) {
tests := []struct {
name string
lbs []godo.LoadBalancer
newLB godo.LoadBalancer
expectedIDMap map[string]*godo.LoadBalancer
expectedNameMap map[string]*godo.LoadBalancer
}{
{
name: "update existing",
lbs: []godo.LoadBalancer{{ID: "1", Name: "one"}},
newLB: godo.LoadBalancer{ID: "1", Name: "new"},
expectedIDMap: map[string]*godo.LoadBalancer{
"1": {ID: "1", Name: "new"},
},
expectedNameMap: map[string]*godo.LoadBalancer{
"new": {ID: "1", Name: "new"},
},
},
{
name: "update new",
lbs: []godo.LoadBalancer{{ID: "1", Name: "one"}},
newLB: godo.LoadBalancer{ID: "2", Name: "two"},
expectedIDMap: map[string]*godo.LoadBalancer{
"1": {ID: "1", Name: "one"},
"2": {ID: "2", Name: "two"},
},
expectedNameMap: map[string]*godo.LoadBalancer{
"one": {ID: "1", Name: "one"},
"two": {ID: "2", Name: "two"},
},
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
resources := newResources("", "", nil)
resources.UpdateLoadBalancers(test.lbs)
resources.AddLoadBalancer(test.newLB)
if want, got := test.expectedIDMap, resources.loadBalancerIDMap; !reflect.DeepEqual(want, got) {
t.Errorf("incorrect id map\nwant :%#v\n got: %#v", want, got)
}
if want, got := test.expectedNameMap, resources.loadBalancerNameMap; !reflect.DeepEqual(want, got) {
t.Errorf("incorrect name map\nwant :%#v\n got: %#v", want, got)
}
})
}
} | explode_data.jsonl/28023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 724
} | [
2830,
3393,
11277,
21346,
5879,
93825,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
8810,
1279,
1797,
3056,
70,
6004,
13969,
93825,
198,
197,
8638,
34068,
1843,
342,
6004,
13969,
93825,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestShowSnippet(t *testing.T) {
app := newTestApp(t)
// start up a https test server
ts := newTestServer(t, app.routes())
defer ts.Close()
tests := []struct {
name string
urlPath string
wantCode int
wantBody []byte
}{
{"Valid ID", "/snippet/1", http.StatusOK, []byte("An old silent pond...")},
{"Non-existent ID", "/snippet/2", http.StatusNotFound, nil},
{"Negative ID", "/snippet/-1", http.StatusNotFound, nil},
{"Decimal ID", "/snippet/1.23", http.StatusNotFound, nil},
{"String ID", "/snippet/foo", http.StatusNotFound, nil},
{"Empty ID", "/snippet/", http.StatusNotFound, nil},
{"Trailing slash", "/snippet/1/", http.StatusNotFound, nil},
{"Internal Error", "/snippet/66", http.StatusInternalServerError, nil},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
code, _, body := ts.get(t, tt.urlPath)
if code != tt.wantCode {
t.Errorf("want %d; got %d", tt.wantCode, code)
}
if !bytes.Contains(body, tt.wantBody) {
t.Errorf("want body to contain %q", tt.wantBody)
}
})
}
} | explode_data.jsonl/12757 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 444
} | [
2830,
3393,
7812,
87852,
1155,
353,
8840,
836,
8,
341,
28236,
1669,
501,
2271,
2164,
1155,
692,
197,
322,
1191,
705,
264,
3703,
1273,
3538,
198,
57441,
1669,
501,
2271,
5475,
1155,
11,
906,
39306,
2398,
16867,
10591,
10421,
2822,
78216,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDescendantNames(t *testing.T) {
// Test a tree has the following structure:
// a
// / \
// / \
// b c
// / | \ / \
// x y z 123 456
// |
// 789
kinship := map[string][]string{
"a": []string{"b", "c"},
"b": []string{"x", "y", "z"},
"c": []string{"123", "456"},
"123": []string{"789"},
}
// Create the forest
f := NewForest()
for parentName, childrenNames := range kinship {
parent := f.Get(parentName)
for _, childName := range childrenNames {
child := f.Get(childName)
child.SetParent(parent)
}
}
tests := []struct {
name string
root string
want []string
}{
{name: "no descendant", root: "456", want: nil},
{name: "one descendant", root: "123", want: []string{"789"}},
{name: "one-level descendants", root: "b", want: []string{"x", "y", "z"}},
{name: "two-level descendants", root: "c", want: []string{"123", "456", "789"}},
{name: "three-level descendants", root: "a", want: []string{"b", "c", "x", "y", "z", "123", "456", "789"}},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
g := NewGomegaWithT(t)
root := f.Get(tc.root)
g.Expect(root.DescendantNames()).Should(Equal(tc.want))
})
}
} | explode_data.jsonl/28407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 556
} | [
2830,
3393,
11065,
20372,
7980,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
264,
4916,
702,
279,
2701,
5944,
510,
197,
322,
260,
264,
198,
197,
322,
981,
608,
220,
3044,
197,
322,
257,
608,
257,
3044,
197,
322,
262,
293,
981,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSnowballDoubleAdd(t *testing.T) {
params := Parameters{
Metrics: prometheus.NewRegistry(),
K: 1, Alpha: 1, BetaVirtuous: 3, BetaRogue: 5,
}
tree := Tree{}
tree.Initialize(params, Red)
tree.Add(Red)
{
expected := "SB(NumSuccessfulPolls = 0, SF(Confidence = 0, Finalized = false)) Bits = [0, 256)"
if str := tree.String(); expected != str {
t.Fatalf("Wrong string. Expected:\n%s\ngot:\n%s", expected, str)
} else if pref := tree.Preference(); !Red.Equals(pref) {
t.Fatalf("Wrong preference. Expected %s got %s", Red, pref)
} else if tree.Finalized() {
t.Fatalf("Finalized too early")
}
}
} | explode_data.jsonl/56480 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
62285,
3959,
7378,
2212,
1155,
353,
8840,
836,
8,
341,
25856,
1669,
13522,
515,
197,
9209,
13468,
25,
2706,
39705,
7121,
15603,
3148,
197,
39340,
25,
981,
220,
16,
11,
24708,
25,
220,
16,
11,
34243,
53,
2106,
9193,
25,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFormatTxEncode(t *testing.T) {
data, err := FormatTxEncode("coins", &Transaction{
Payload: []byte("this is a test."),
})
assert.Equal(t, err, nil)
var tx Transaction
err = Decode(data, &tx)
assert.Equal(t, err, nil)
assert.Equal(t, tx.Execer, []byte("coins"))
} | explode_data.jsonl/52307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
4061,
31584,
32535,
1155,
353,
8840,
836,
8,
972,
8924,
11,
1848,
1669,
15042,
31584,
32535,
445,
29609,
497,
609,
8070,
1666,
197,
10025,
6989,
25,
3056,
3782,
445,
574,
374,
220,
264,
1273,
1189,
9912,
197,
35099,
6948,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoggingServiceV2ListMonitoredResourceDescriptors(t *testing.T) {
var nextPageToken string = ""
var resourceDescriptorsElement *monitoredrespb.MonitoredResourceDescriptor = &monitoredrespb.MonitoredResourceDescriptor{}
var resourceDescriptors = []*monitoredrespb.MonitoredResourceDescriptor{resourceDescriptorsElement}
var expectedResponse = &loggingpb.ListMonitoredResourceDescriptorsResponse{
NextPageToken: nextPageToken,
ResourceDescriptors: resourceDescriptors,
}
mockLogging.err = nil
mockLogging.reqs = nil
mockLogging.resps = append(mockLogging.resps[:0], expectedResponse)
var request *loggingpb.ListMonitoredResourceDescriptorsRequest = &loggingpb.ListMonitoredResourceDescriptorsRequest{}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
resp, err := c.ListMonitoredResourceDescriptors(context.Background(), request).Next()
if err != nil {
t.Fatal(err)
}
if want, got := request, mockLogging.reqs[0]; !proto.Equal(want, got) {
t.Errorf("wrong request %q, want %q", got, want)
}
want := (interface{})(expectedResponse.ResourceDescriptors[0])
got := (interface{})(resp)
var ok bool
switch want := (want).(type) {
case proto.Message:
ok = proto.Equal(want, got.(proto.Message))
default:
ok = want == got
}
if !ok {
t.Errorf("wrong response %q, want %q)", got, want)
}
} | explode_data.jsonl/77763 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 481
} | [
2830,
3393,
34575,
1860,
53,
17,
852,
11095,
36201,
4783,
58553,
1155,
353,
8840,
836,
8,
341,
2405,
83595,
3323,
914,
284,
8389,
2405,
5101,
58553,
1691,
353,
1645,
36201,
416,
16650,
52211,
36201,
4783,
11709,
284,
609,
1645,
36201,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.