Skip to content

Commit c1efb6c

Browse files
author
miaoxiaowei1112
committed
merge dataset_oneline.jsonl to samples_all.jsonl
1 parent 902d13f commit c1efb6c

File tree

10 files changed

+440
-1466
lines changed

10 files changed

+440
-1466
lines changed

src/main/java/com/aixcode/autoTest/GenerateMethodBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public abstract class GenerateMethodBase {
190190
public void move(Path src, Path dest) throws Exception {throw new RuntimeException("Not implemented");}
191191
public <K, V> Map<V, Set<K> > reverseMapIntoValueSetMap(Map<K, V> map) throws Exception {throw new RuntimeException("Not implemented");}
192192
public byte[] base64decode(String base64string) throws Exception {throw new RuntimeException("Not implemented");}
193-
public <T> T initByReflect(String name, Object value, T t) throws Exception {throw new RuntimeException("Not implemented");}
193+
public <T> T initByReflect(String name, String value, T t) throws Exception {throw new RuntimeException("Not implemented");}
194194
public <T> List<T> array2List(T[] array) throws Exception {throw new RuntimeException("Not implemented");}
195195
public List<String> getWeekDate() throws Exception {throw new RuntimeException("Not implemented");}
196196
public long remaining(ByteBuffer[] buffers) throws Exception {throw new RuntimeException("Not implemented");}

src/main/java/com/aixcode/autoTest/evaluation/Evaluation120.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ public Evaluation120(String basePackage, String prefix) {
1515
public int[] evaluation() {
1616
int pass_count = 0;
1717
Map<double[],Integer> map = new HashMap<>(){{
18-
put(new double[] {1,2},-1);
19-
put(new double[]{2,1}, 1);
20-
put(new double[] {1, 1}, 0);
21-
put(new double[] {-1, -1}, 0);
22-
put(new double[] {-1, -2}, 1);
18+
put(new double[] {1000000.675d,Double.NaN},-1);// NaN is lager than all double values, including PositiveInfinity
19+
put(new double[] {Double.NaN,Double.NaN},0);//NaN is equal to NaN
20+
put(new double[] {Double.NaN,Double.POSITIVE_INFINITY},1);//// NaN is lager than all double values, including PositiveInfinity
21+
put(new double[]{+0.0d,-0,0d}, 1);// +0.0d is larger than -0.0d
22+
put(new double[] {123.567d, 123.567d}, 0); // normal double values compare
23+
put(new double[] {-123.321d, Double.NEGATIVE_INFINITY}, 1);// negative double value larger than negative infinity
24+
put(new double[] {123.009d, Double.POSITIVE_INFINITY}, -1);// positive double value smaller than positive infinity
2325
}};
2426
for (Map.Entry<double[], Integer> entry : map.entrySet()){
2527
try {

src/main/java/com/aixcode/autoTest/evaluation/Evaluation121.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ public Evaluation121(String basePackage, String prefix) {
1515
public int[] evaluation() {
1616
int pass_count = 0;
1717
Map<String,Integer> map = new HashMap<>(){{
18-
put("",-1);
19-
put("/users",0);
20-
put("users/com",5);
21-
put("pass/",4);
22-
put("emails/to", 6);
18+
put(" ",-1);// not found
19+
put("/users",0);//first one
20+
put("users/",5);//last one
21+
put("users/com",5); //in the middle
22+
put("/////",0); //many slashes
23+
put("emails\n\0/", 8); //after particular char
2324
}};
2425
for (Map.Entry<String,Integer> entry : map.entrySet()){
2526
try {
26-
if (solution.getNextSlash(entry.getKey(), 0) == entry.getValue()){
27+
int result = solution.getNextSlash(entry.getKey(), 0);
28+
if (result == entry.getValue()){
2729
pass_count++;
2830
}
2931
}catch (Exception e) {

src/main/java/com/aixcode/autoTest/evaluation/Evaluation122.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ public Evaluation122(String basePackage, String prefix) {
1515
public int[] evaluation() {
1616
int pass_count = 0;
1717
Map<long[][],Boolean> map = new HashMap<>(){{
18-
put(new long[][]{{-1},{1}}, false);
19-
put(new long[][]{{-3}, {1,12}}, false);
20-
put(new long[][]{{1},{2}}, true);
21-
put(new long[][]{{1,2},{}}, true);
18+
put(new long[][]{{-1},{1}}, false);//contain negative array
19+
put(new long[][]{null, {1,12}}, false);//contain null array
20+
put(new long[][]{{1},{2}}, true);//all positive array
21+
put(new long[][]{{1,2},{}}, true);//contain empty array
2222
put(new long[][]{{1,2},{-2}}, false);
23+
put(null, false);
2324
}};
2425
for (Map.Entry<long[][],Boolean> entry : map.entrySet()){
2526
try {

src/main/java/com/aixcode/autoTest/evaluation/Evaluation166.java

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.aixcode.autoTest.AbstractBaseEvaluation;
44
import com.aixcode.sampleHelper.Student;
55

6-
import java.util.ArrayList;
7-
import java.util.List;
6+
import java.util.HashMap;
7+
import java.util.Map;
88

99
public class Evaluation166 extends AbstractBaseEvaluation {
1010
public Evaluation166(String basePackage, String prefix) {
@@ -15,49 +15,33 @@ public Evaluation166(String basePackage, String prefix) {
1515
public int[] evaluation() {
1616
int passCount = 0;
1717
Student student=new Student();
18-
19-
try {
20-
student=solution.initByReflect("name","musk",student);
21-
if ("musk".equals(student.name)) {
22-
passCount++;
23-
}
24-
}catch (Exception e){
25-
26-
}
27-
try {
28-
student=solution.initByReflect("age",18,student);
29-
if (18==student.getAge()) {
30-
passCount++;
31-
}
32-
33-
}catch (Exception e){
34-
35-
}
36-
try {
37-
List<String> teachers=new ArrayList<>(){
38-
{
39-
add("teacher1");
40-
add("teacher2");
41-
add("teacher3");
18+
Map<String,String> map = new HashMap<>(){
19+
{
20+
put("name1", "lucky");
21+
put("name2", null);
22+
put("name3", "");
23+
put("teachers", "{\"teacher1\",\"teacher2\"}");//给数组类型赋值
24+
put("age", String.valueOf(18));//给整型的值赋值
25+
}};
26+
27+
for (Map.Entry<String, String> entry : map.entrySet()) {
28+
String key = entry.getKey();
29+
String value = entry.getValue();
30+
try {
31+
student=solution.initByReflect(key,value,student);
32+
} catch(IllegalArgumentException ex){
33+
//System.out.println("IllegalArgumentException");
34+
} catch (Exception e){
4235
}
43-
};
44-
student=solution.initByReflect("teachers",teachers,student);
45-
List<String> reflectTeachers=student.getTeachers();
4636

47-
if(teachers!=null&&teachers.size()==reflectTeachers.size()){
48-
if (teachers.containsAll(reflectTeachers)&&reflectTeachers.containsAll(teachers)) {
37+
if (value == null && value == student.getValueByName(key)) {
38+
passCount++;
39+
} else if (value != null && value.equals(student.getValueByName(key))) {
4940
passCount++;
5041
}
51-
5242
}
53-
}catch (Exception e){
54-
55-
}
56-
57-
58-
5943

60-
return new int[]{passCount,3};
44+
return new int[]{passCount,map.size()};
6145
}
6246

6347
}

src/main/java/com/aixcode/autoTest/generate/aixcoder/Aixcoder166.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,19 @@ public class Aixcoder166 extends GenerateMethodBase {
88
/**
99
* 通过反射为对象的对应字段注入值
1010
*/
11-
public<T> T initByReflect(String name, Object value, T t) {
12-
if (null == t) {
13-
throw new NullPointerException("t can not be null");
14-
}
15-
16-
if (null == value) {
17-
return null;
18-
}
19-
20-
Class<?> clazz = t.getClass();
21-
22-
if (!clazz.isAssignableFrom(value.getClass())) {
23-
throw new IllegalArgumentException("value must be assignable to" + clazz);
24-
}
25-
11+
public<T> T initByReflect(String name, String value, T t) {
2612
try {
27-
Field field = clazz.getDeclaredField(name);
28-
field.setAccessible(true);
29-
field.set(t, value);
30-
} catch (NoSuchFieldException e) {
31-
throw new IllegalArgumentException("no such field:" + name);
32-
} catch (IllegalAccessException e) {
33-
throw new IllegalArgumentException("illegal access:" + name);
13+
Class<?> clazz = t.getClass();
14+
Field[] fields = clazz.getDeclaredFields();
15+
16+
for (Field field : fields) {
17+
if (field.getName().equals(name)) {
18+
field.setAccessible(true);
19+
field.set(t, value);
20+
}
21+
}
22+
} catch (Exception e) {
23+
//e.printStackTrace();
3424
}
3525

3626
return t;

src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod166.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ public class GenerateMethod166 extends GenerateMethodBase {
88
/**
99
* 通过反射为对象的对应字段注入值
1010
*/
11-
public <T> T initByReflect(String name, Object value, T t) {
12-
try {
13-
Field field = t.getClass().getDeclaredField(name);
14-
field.setAccessible(true);
15-
field.set(t, value);
16-
} catch (Exception e) {
17-
e.printStackTrace();
18-
}
11+
public <T> T initByReflect(String name, String value, T t) throws Exception {
12+
Field field = t.getClass().getDeclaredField(name);
13+
field.setAccessible(true);
14+
field.set(t, value);
1915
return t;
2016
}
2117
}

src/main/java/com/aixcode/sampleHelper/Student.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,49 @@
33
import java.util.List;
44

55
public class Student {
6-
public String name;
6+
public String name1;
7+
public String name2;
8+
public String name3;
9+
10+
711
private Integer age;
812
public List<String> teachers;
913

1014
public Student() {
1115
}
1216

1317
public Student(String name, Integer age, List<String> teachers) {
14-
this.name = name;
18+
this.name1 = name;
1519
this.age = age;
1620
this.teachers = teachers;
1721
}
1822

19-
public String getName() {
20-
return name;
23+
public void setName1(String name) {
24+
this.name1 = name;
25+
}
26+
public void setName2(String name) {
27+
this.name2 = name;
28+
}
29+
public void setName3(String name) {
30+
this.name3 = name;
2131
}
2232

23-
public void setName(String name) {
24-
this.name = name;
33+
public String getValueByName(String name) {
34+
try {
35+
if ("name1".equals(name)) {
36+
return name1;
37+
} else if ("name2".equals(name)) {
38+
return name2;
39+
} else if ("name3".equals(name)) {
40+
return name3;
41+
} else if ("age".equals(name)) {
42+
return String.valueOf(age);
43+
} else if ("teachers".equals(name)) {
44+
return teachers.toString();
45+
}
46+
} catch (Exception e) {
47+
}
48+
return null;
2549
}
2650

2751
public Integer getAge() {

0 commit comments

Comments
 (0)