-
Notifications
You must be signed in to change notification settings - Fork 47
/
AssertEqualsBooleanTest.java
158 lines (113 loc) · 4.95 KB
/
AssertEqualsBooleanTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package com.sap.adt.abapcleaner.rules.commands;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.sap.adt.abapcleaner.rulebase.RuleID;
import com.sap.adt.abapcleaner.rulebase.RuleTestBase;
class AssertEqualsBooleanTest extends RuleTestBase {
private AssertEqualsBooleanRule rule;
AssertEqualsBooleanTest() {
super(RuleID.ASSERT_EQUALS_BOOLEAN);
rule = (AssertEqualsBooleanRule)getRule();
}
@BeforeEach
void setUp() {
// setup default test configuration (may be modified in the individual test methods)
rule.configRemoveActIfOnlyParameter.setValue(true);
}
@Test
void testSimpleExpAct() {
rule.configRemoveActIfOnlyParameter.setValue(true);
buildSrc(" cl_abap_unit_assert=>assert_equals( exp = abap_false");
buildSrc(" act = lv_value ).");
buildExp(" cl_abap_unit_assert=>assert_false( lv_value ).");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testSimpleExpActKeepParamName() {
rule.configRemoveActIfOnlyParameter.setValue(false);
buildSrc(" cl_abap_unit_assert=>assert_equals( exp = abap_false");
buildSrc(" act = lv_value ).");
buildExp(" cl_abap_unit_assert=>assert_false( act = lv_value ).");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testComplexActExp() {
rule.configRemoveActIfOnlyParameter.setValue(true);
buildSrc(" cl_abap_unit_assert=>assert_equals( act = mo_instance->is_valid( )");
buildSrc(" exp = abap_true ).");
buildExp(" cl_abap_unit_assert=>assert_true( mo_instance->is_valid( ) ).");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testComplexActExpKeepParamName() {
rule.configRemoveActIfOnlyParameter.setValue(false);
buildSrc(" cl_abap_unit_assert=>assert_equals( act = mo_instance->is_valid( )");
buildSrc(" exp = abap_true ).");
buildExp(" cl_abap_unit_assert=>assert_true( act = mo_instance->is_valid( ) ).");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testComplexActExpWithCommentOnAct() {
buildSrc(" cl_abap_unit_assert=>assert_equals( act = mo_instance->is_valid( ) \" comment on act");
buildSrc(" exp = abap_true ).");
buildExp(" cl_abap_unit_assert=>assert_true( act = mo_instance->is_valid( ) ). \" comment on act");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testComplexActExpWithCommentOnExp() {
buildSrc(" cl_abap_unit_assert=>assert_equals( act = mo_instance->is_valid( )");
buildSrc(" exp = abap_true \" comment on exp");
buildSrc(" ).");
buildExp(" cl_abap_unit_assert=>assert_true( act = mo_instance->is_valid( ) ). \" comment on exp");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testExpActWithCommentOnExp() {
buildSrc(" cl_abap_unit_assert=>assert_equals( exp = abap_false \" comment on exp");
buildSrc(" act = lv_value ).");
buildExp(" cl_abap_unit_assert=>assert_false( \" comment on exp");
buildExp(" act = lv_value ).");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testWithMsgParameter() {
buildSrc(" cl_abap_unit_assert=>assert_equals( act = lv_value");
buildSrc(" exp = abap_true");
buildSrc(" msg = 'message' ).");
buildExp(" cl_abap_unit_assert=>assert_true( act = lv_value");
buildExp(" msg = 'message' ).");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testMultiParamsWithLineEndComments() {
buildSrc(" cl_abap_unit_assert=>assert_equals(");
buildSrc(" act = lv_value \" comment on act");
buildSrc(" exp = abap_false \" comment on exp");
buildSrc(" msg = 'message' \" comment on msg");
buildSrc(" quit = lv_quit ).");
buildSrc("");
buildSrc(" cl_abap_unit_assert=>assert_equals(");
buildSrc(" act = lv_value \" comment on act");
buildSrc(" exp = abap_true");
buildSrc(" msg = 'message' ). \" comment on msg");
buildExp(" cl_abap_unit_assert=>assert_false(");
buildExp(" act = lv_value \" comment on act");
buildExp(" \" comment on exp");
buildExp(" msg = 'message' \" comment on msg");
buildExp(" quit = lv_quit ).");
buildExp("");
buildExp(" cl_abap_unit_assert=>assert_true(");
buildExp(" act = lv_value \" comment on act");
buildExp(" msg = 'message' ). \" comment on msg");
putAnyMethodAroundSrcAndExp();
testRule();
}
}