Reviewed By: akotulski Differential Revision: D3069663 fb-gh-sync-id: c1d794c shipit-source-id: c1d794cmaster
parent
037c257c4f
commit
c6524d799f
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Person {
|
||||||
|
public:
|
||||||
|
Person(int i) { x = i; }
|
||||||
|
|
||||||
|
Person(int i, int j, int k) {
|
||||||
|
x = i;
|
||||||
|
y = j;
|
||||||
|
z = k;
|
||||||
|
}
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
};
|
||||||
|
|
||||||
|
int getValue(int x) { return x; }
|
||||||
|
|
||||||
|
int constructor_1_arg_new_div0() {
|
||||||
|
Person* p = new Person(5);
|
||||||
|
return 1 / (p->x - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
int constructor_3_args_new_div0() {
|
||||||
|
Person* p = new Person(5, 6, 7);
|
||||||
|
return 1 / (p->z - 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
int int_init_number() {
|
||||||
|
int* x1 = new int(5);
|
||||||
|
return 1 / (*x1 - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
float float_init_number() {
|
||||||
|
float* x1 = new float(5.4);
|
||||||
|
return 1 / (*x1 - 5.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
int int_init_empty() {
|
||||||
|
int* x1 = new int();
|
||||||
|
return 1 / *x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int int_init_empty_list() {
|
||||||
|
int x1{};
|
||||||
|
return 1 / x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int int_init_empty_list_new() {
|
||||||
|
int* x1 = new int{};
|
||||||
|
return 1 / *x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int int_init_nodes() {
|
||||||
|
int z = 6;
|
||||||
|
int* y = new int(getValue(4));
|
||||||
|
int* x = new int(getValue(0) ? getValue(1) : 1 + *y);
|
||||||
|
return 1 / (*x - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
int constructor_nodes() {
|
||||||
|
int z = 6;
|
||||||
|
Person* p = new Person(getValue(0) ? getValue(1) : 1 + z);
|
||||||
|
return 1 / (p->x - 7);
|
||||||
|
}
|
@ -0,0 +1,240 @@
|
|||||||
|
digraph iCFG {
|
||||||
|
62 [label="62: DeclStmt \n *&z:int =6 [line 69]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
62 -> 56 ;
|
||||||
|
61 [label="61: DeclStmt \n n$2=_fun___new(sizeof(class Person ):unsigned long ) [line 70]\n n$6=*&SIL_temp_conditional___55:int [line 70]\n NULLIFY(&SIL_temp_conditional___55,true); [line 70]\n _fun_Person_Person(n$2:class Person *,n$6:int ) [line 70]\n *&p:class Person *=n$2 [line 70]\n REMOVE_TEMPS(n$2,n$6); [line 70]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
61 -> 54 ;
|
||||||
|
60 [label="60: ConditinalStmt Branch \n n$5=*&z:int [line 70]\n DECLARE_LOCALS(&SIL_temp_conditional___55); [line 70]\n *&SIL_temp_conditional___55:int =(1 + n$5) [line 70]\n REMOVE_TEMPS(n$5); [line 70]\n NULLIFY(&z,false); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
60 -> 55 ;
|
||||||
|
59 [label="59: ConditinalStmt Branch \n NULLIFY(&z,false); [line 70]\n n$4=_fun_getValue(1:int ) [line 70]\n DECLARE_LOCALS(&SIL_temp_conditional___55); [line 70]\n *&SIL_temp_conditional___55:int =n$4 [line 70]\n REMOVE_TEMPS(n$4); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
59 -> 55 ;
|
||||||
|
58 [label="58: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 70]\n REMOVE_TEMPS(n$3); [line 70]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
58 -> 60 ;
|
||||||
|
57 [label="57: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 70]\n REMOVE_TEMPS(n$3); [line 70]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
57 -> 59 ;
|
||||||
|
56 [label="56: Call _fun_getValue \n n$3=_fun_getValue(0:int ) [line 70]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
56 -> 57 ;
|
||||||
|
56 -> 58 ;
|
||||||
|
55 [label="55: + \n " ]
|
||||||
|
|
||||||
|
|
||||||
|
55 -> 61 ;
|
||||||
|
54 [label="54: Return Stmt \n n$0=*&p:class Person * [line 71]\n n$1=*n$0.x:int [line 71]\n *&return:int =(1 / (n$1 - 7)) [line 71]\n REMOVE_TEMPS(n$0,n$1); [line 71]\n NULLIFY(&p,false); [line 71]\n APPLY_ABSTRACTION; [line 71]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
54 -> 53 ;
|
||||||
|
53 [label="53: Exit constructor_nodes \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
52 [label="52: Start constructor_nodes\nFormals: \nLocals: p:class Person * z:int \n DECLARE_LOCALS(&return,&p,&z); [line 68]\n NULLIFY(&p,false); [line 68]\n NULLIFY(&z,false); [line 68]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
52 -> 62 ;
|
||||||
|
51 [label="51: DeclStmt \n *&z:int =6 [line 62]\n NULLIFY(&z,false); [line 62]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
51 -> 50 ;
|
||||||
|
50 [label="50: DeclStmt \n n$8=_fun___new(sizeof(int ):unsigned long ) [line 63]\n n$9=_fun_getValue(4:int ) [line 63]\n *n$8:int =n$9 [line 63]\n *&y:int *=n$8 [line 63]\n REMOVE_TEMPS(n$8,n$9); [line 63]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
50 -> 44 ;
|
||||||
|
49 [label="49: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 64]\n n$7=*&SIL_temp_conditional___43:int [line 64]\n NULLIFY(&SIL_temp_conditional___43,true); [line 64]\n *n$2:int =n$7 [line 64]\n *&x:int *=n$2 [line 64]\n REMOVE_TEMPS(n$2,n$7); [line 64]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
49 -> 42 ;
|
||||||
|
48 [label="48: ConditinalStmt Branch \n n$5=*&y:int * [line 64]\n n$6=*n$5:int [line 64]\n DECLARE_LOCALS(&SIL_temp_conditional___43); [line 64]\n *&SIL_temp_conditional___43:int =(1 + n$6) [line 64]\n REMOVE_TEMPS(n$5,n$6); [line 64]\n NULLIFY(&y,false); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
48 -> 43 ;
|
||||||
|
47 [label="47: ConditinalStmt Branch \n NULLIFY(&y,false); [line 64]\n n$4=_fun_getValue(1:int ) [line 64]\n DECLARE_LOCALS(&SIL_temp_conditional___43); [line 64]\n *&SIL_temp_conditional___43:int =n$4 [line 64]\n REMOVE_TEMPS(n$4); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
47 -> 43 ;
|
||||||
|
46 [label="46: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 64]\n REMOVE_TEMPS(n$3); [line 64]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
46 -> 48 ;
|
||||||
|
45 [label="45: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 64]\n REMOVE_TEMPS(n$3); [line 64]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
45 -> 47 ;
|
||||||
|
44 [label="44: Call _fun_getValue \n n$3=_fun_getValue(0:int ) [line 64]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
44 -> 45 ;
|
||||||
|
44 -> 46 ;
|
||||||
|
43 [label="43: + \n " ]
|
||||||
|
|
||||||
|
|
||||||
|
43 -> 49 ;
|
||||||
|
42 [label="42: Return Stmt \n n$0=*&x:int * [line 65]\n n$1=*n$0:int [line 65]\n *&return:int =(1 / (n$1 - 5)) [line 65]\n REMOVE_TEMPS(n$0,n$1); [line 65]\n NULLIFY(&x,false); [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
42 -> 41 ;
|
||||||
|
41 [label="41: Exit int_init_nodes \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
40 [label="40: Start int_init_nodes\nFormals: \nLocals: x:int * y:int * z:int \n DECLARE_LOCALS(&return,&x,&y,&z); [line 61]\n NULLIFY(&x,false); [line 61]\n NULLIFY(&y,false); [line 61]\n NULLIFY(&z,false); [line 61]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
40 -> 51 ;
|
||||||
|
39 [label="39: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 57]\n *n$2:int *=0 [line 57]\n *&x1:int *=n$2 [line 57]\n REMOVE_TEMPS(n$2); [line 57]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
39 -> 38 ;
|
||||||
|
38 [label="38: Return Stmt \n n$0=*&x1:int * [line 58]\n n$1=*n$0:int [line 58]\n *&return:int =(1 / n$1) [line 58]\n REMOVE_TEMPS(n$0,n$1); [line 58]\n NULLIFY(&x1,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
38 -> 37 ;
|
||||||
|
37 [label="37: Exit int_init_empty_list_new \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
36 [label="36: Start int_init_empty_list_new\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 56]\n NULLIFY(&x1,false); [line 56]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
36 -> 39 ;
|
||||||
|
35 [label="35: DeclStmt \n *&x1:int =0 [line 52]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
35 -> 34 ;
|
||||||
|
34 [label="34: Return Stmt \n n$0=*&x1:int [line 53]\n *&return:int =(1 / n$0) [line 53]\n REMOVE_TEMPS(n$0); [line 53]\n NULLIFY(&x1,false); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
34 -> 33 ;
|
||||||
|
33 [label="33: Exit int_init_empty_list \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
32 [label="32: Start int_init_empty_list\nFormals: \nLocals: x1:int \n DECLARE_LOCALS(&return,&x1); [line 51]\n NULLIFY(&x1,false); [line 51]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
32 -> 35 ;
|
||||||
|
31 [label="31: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 47]\n *n$2:int =0 [line 47]\n *&x1:int *=n$2 [line 47]\n REMOVE_TEMPS(n$2); [line 47]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
31 -> 30 ;
|
||||||
|
30 [label="30: Return Stmt \n n$0=*&x1:int * [line 48]\n n$1=*n$0:int [line 48]\n *&return:int =(1 / n$1) [line 48]\n REMOVE_TEMPS(n$0,n$1); [line 48]\n NULLIFY(&x1,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
30 -> 29 ;
|
||||||
|
29 [label="29: Exit int_init_empty \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
28 [label="28: Start int_init_empty\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 46]\n NULLIFY(&x1,false); [line 46]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
28 -> 31 ;
|
||||||
|
27 [label="27: DeclStmt \n n$2=_fun___new(sizeof(float ):unsigned long ) [line 42]\n *n$2:float =5.400000 [line 42]\n *&x1:float *=n$2 [line 42]\n REMOVE_TEMPS(n$2); [line 42]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
27 -> 26 ;
|
||||||
|
26 [label="26: Return Stmt \n n$0=*&x1:float * [line 43]\n n$1=*n$0:float [line 43]\n *&return:float =(1 / (n$1 - 5.400000)) [line 43]\n REMOVE_TEMPS(n$0,n$1); [line 43]\n NULLIFY(&x1,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
26 -> 25 ;
|
||||||
|
25 [label="25: Exit float_init_number \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
24 [label="24: Start float_init_number\nFormals: \nLocals: x1:float * \n DECLARE_LOCALS(&return,&x1); [line 41]\n NULLIFY(&x1,false); [line 41]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
24 -> 27 ;
|
||||||
|
23 [label="23: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 37]\n *n$2:int =5 [line 37]\n *&x1:int *=n$2 [line 37]\n REMOVE_TEMPS(n$2); [line 37]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
23 -> 22 ;
|
||||||
|
22 [label="22: Return Stmt \n n$0=*&x1:int * [line 38]\n n$1=*n$0:int [line 38]\n *&return:int =(1 / (n$1 - 5)) [line 38]\n REMOVE_TEMPS(n$0,n$1); [line 38]\n NULLIFY(&x1,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
22 -> 21 ;
|
||||||
|
21 [label="21: Exit int_init_number \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
20 [label="20: Start int_init_number\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 36]\n NULLIFY(&x1,false); [line 36]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
20 -> 23 ;
|
||||||
|
19 [label="19: DeclStmt \n n$2=_fun___new(sizeof(class Person ):unsigned long ) [line 32]\n _fun_Person_Person(n$2:class Person *,5:int ,6:int ,7:int ) [line 32]\n *&p:class Person *=n$2 [line 32]\n REMOVE_TEMPS(n$2); [line 32]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
19 -> 18 ;
|
||||||
|
18 [label="18: Return Stmt \n n$0=*&p:class Person * [line 33]\n n$1=*n$0.z:int [line 33]\n *&return:int =(1 / (n$1 - 7)) [line 33]\n REMOVE_TEMPS(n$0,n$1); [line 33]\n NULLIFY(&p,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
18 -> 17 ;
|
||||||
|
17 [label="17: Exit constructor_3_args_new_div0 \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
16 [label="16: Start constructor_3_args_new_div0\nFormals: \nLocals: p:class Person * \n DECLARE_LOCALS(&return,&p); [line 31]\n NULLIFY(&p,false); [line 31]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
16 -> 19 ;
|
||||||
|
15 [label="15: DeclStmt \n n$2=_fun___new(sizeof(class Person ):unsigned long ) [line 27]\n _fun_Person_Person(n$2:class Person *,5:int ) [line 27]\n *&p:class Person *=n$2 [line 27]\n REMOVE_TEMPS(n$2); [line 27]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
15 -> 14 ;
|
||||||
|
14 [label="14: Return Stmt \n n$0=*&p:class Person * [line 28]\n n$1=*n$0.x:int [line 28]\n *&return:int =(1 / (n$1 - 5)) [line 28]\n REMOVE_TEMPS(n$0,n$1); [line 28]\n NULLIFY(&p,false); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
14 -> 13 ;
|
||||||
|
13 [label="13: Exit constructor_1_arg_new_div0 \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
12 [label="12: Start constructor_1_arg_new_div0\nFormals: \nLocals: p:class Person * \n DECLARE_LOCALS(&return,&p); [line 26]\n NULLIFY(&p,false); [line 26]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
12 -> 15 ;
|
||||||
|
11 [label="11: Return Stmt \n n$0=*&x:int [line 24]\n *&return:int =n$0 [line 24]\n REMOVE_TEMPS(n$0); [line 24]\n NULLIFY(&x,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
11 -> 10 ;
|
||||||
|
10 [label="10: Exit getValue \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
9 [label="9: Start getValue\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
9 -> 11 ;
|
||||||
|
8 [label="8: BinaryOperatorStmt: Assign \n n$4=*&this:class Person * [line 15]\n n$5=*&i:int [line 15]\n *n$4.x:int =n$5 [line 15]\n REMOVE_TEMPS(n$4,n$5); [line 15]\n NULLIFY(&i,false); [line 15]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
8 -> 7 ;
|
||||||
|
7 [label="7: BinaryOperatorStmt: Assign \n n$2=*&this:class Person * [line 16]\n n$3=*&j:int [line 16]\n *n$2.y:int =n$3 [line 16]\n REMOVE_TEMPS(n$2,n$3); [line 16]\n NULLIFY(&j,false); [line 16]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
7 -> 6 ;
|
||||||
|
6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class Person * [line 17]\n n$1=*&k:int [line 17]\n *n$0.z:int =n$1 [line 17]\n REMOVE_TEMPS(n$0,n$1); [line 17]\n NULLIFY(&k,false); [line 17]\n NULLIFY(&this,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
6 -> 5 ;
|
||||||
|
5 [label="5: Exit Person_Person \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
4 [label="4: Start Person_Person\nFormals: this:class Person * i:int j:int k:int \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
4 -> 8 ;
|
||||||
|
3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class Person * [line 12]\n n$1=*&i:int [line 12]\n *n$0.x:int =n$1 [line 12]\n REMOVE_TEMPS(n$0,n$1); [line 12]\n NULLIFY(&i,false); [line 12]\n NULLIFY(&this,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
3 -> 2 ;
|
||||||
|
2 [label="2: Exit Person_Person \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 [label="1: Start Person_Person\nFormals: this:class Person * i:int \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 -> 3 ;
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package endtoend.cpp;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.ClassRule;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import utils.DebuggableTemporaryFolder;
|
||||||
|
import utils.InferException;
|
||||||
|
import utils.InferResults;
|
||||||
|
import utils.InferRunner;
|
||||||
|
|
||||||
|
public class ConstructorNewTest {
|
||||||
|
|
||||||
|
public static final String FILE =
|
||||||
|
"infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp";
|
||||||
|
|
||||||
|
private static ImmutableList<String> inferCmd;
|
||||||
|
|
||||||
|
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
||||||
|
|
||||||
|
@ClassRule
|
||||||
|
public static DebuggableTemporaryFolder folder =
|
||||||
|
new DebuggableTemporaryFolder();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void runInfer() throws InterruptedException, IOException {
|
||||||
|
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
||||||
|
throws InterruptedException, IOException, InferException {
|
||||||
|
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
||||||
|
String[] procedures = {
|
||||||
|
"constructor_1_arg_new_div0",
|
||||||
|
"constructor_3_args_new_div0",
|
||||||
|
"int_init_number",
|
||||||
|
"float_init_number",
|
||||||
|
"int_init_empty",
|
||||||
|
"int_init_empty_list",
|
||||||
|
"int_init_empty_list_new",
|
||||||
|
"int_init_nodes",
|
||||||
|
"constructor_nodes"
|
||||||
|
};
|
||||||
|
assertThat(
|
||||||
|
"Results should contain the expected divide by zero",
|
||||||
|
inferResults,
|
||||||
|
containsExactly(
|
||||||
|
DIVIDE_BY_ZERO,
|
||||||
|
FILE,
|
||||||
|
procedures
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue