|
45 | 45 | import static com.premiumminds.sonar.postgres.PostgresSqlRulesDefinition.RULE_SETTING_NOT_NULLABLE_FIELD; |
46 | 46 | import static com.premiumminds.sonar.postgres.PostgresSqlRulesDefinition.RULE_VACUUM_FULL; |
47 | 47 | import static org.junit.jupiter.api.Assertions.assertEquals; |
48 | | -import static org.junit.jupiter.api.Assertions.assertNull; |
49 | 48 | import static org.junit.jupiter.api.Assertions.assertTrue; |
50 | 49 | import static org.sonar.api.measures.CoreMetrics.NCLOC; |
51 | 50 | import static org.sonar.api.measures.CoreMetrics.NCLOC_DATA; |
@@ -129,13 +128,33 @@ void metricsNcloc() { |
129 | 128 | createFile(contextTester, "file1.sql", "SELECT 1;\r\nSELECT 2;\r\nSELECT 3;"); |
130 | 129 | createFile(contextTester, "file2.sql", "SELECT 'Évora 1';\nSELECT 'Évora 2';\nSELECT 'Évora 3';"); |
131 | 130 | createFile(contextTester, "file3.sql", "INSERT INTO foo VALUES ('éééééééééééé'), ('a');"); |
| 131 | + createFile(contextTester, "file4.sql", "--comment\nSELECT 1;"); |
| 132 | + createFile(contextTester, "file5.sql", "\n" + |
| 133 | + " select bar from foo;;\n" + |
| 134 | + " \n" + |
| 135 | + " select \n" + |
| 136 | + " -- some comment\n" + |
| 137 | + " bar2\n" + |
| 138 | + " ,\n" + |
| 139 | + " baz2\n" + |
| 140 | + " /* some other comment */\n" + |
| 141 | + " from foo2;\n" + |
| 142 | + "\n" + |
| 143 | + "COMMENT ON TABLE mytable IS 'This is my table.';\n" + |
| 144 | + "\n" + |
| 145 | + "create table foo (\n" + |
| 146 | + " like bar\n" + |
| 147 | + " including comments\n" + |
| 148 | + ");\n"); |
132 | 149 |
|
133 | 150 | PostgresSqlSensor sensor = getPostgresSqlSensor(); |
134 | 151 | sensor.execute(contextTester); |
135 | 152 |
|
136 | 153 | assertEquals(3, contextTester.measure(":file1.sql", NCLOC).value()); |
137 | 154 | assertEquals(3, contextTester.measure(":file2.sql", NCLOC).value()); |
138 | 155 | assertEquals(1, contextTester.measure(":file3.sql", NCLOC).value()); |
| 156 | + assertEquals(1, contextTester.measure(":file4.sql", NCLOC).value()); |
| 157 | + assertEquals(11, contextTester.measure(":file5.sql", NCLOC).value()); |
139 | 158 | } |
140 | 159 |
|
141 | 160 | @Test |
|
0 commit comments