mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[formatter] fix CompositeWhiteSpaceFormattingStrategy::check
GitOrigin-RevId: cdd4b80c1b5b4dda5fc188b998627246b7a2851b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e30acbd73
commit
4be13e8463
+1
-1
@@ -57,7 +57,7 @@ public class CompositeWhiteSpaceFormattingStrategy implements WhiteSpaceFormatti
|
||||
}
|
||||
}
|
||||
if (offset == oldOffset) {
|
||||
return start;
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
return offset;
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.formatter
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class CompositeWhiteSpaceStrategyTest {
|
||||
|
||||
private lateinit var myStrategy: CompositeWhiteSpaceFormattingStrategy
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
myStrategy = CompositeWhiteSpaceFormattingStrategy(listOf(
|
||||
StaticSymbolWhiteSpaceDefinitionStrategy('a', 'c'),
|
||||
StaticSymbolWhiteSpaceDefinitionStrategy('a', 'b')
|
||||
))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun failOnTheFirstSymbol() {
|
||||
Assert.assertSame(0, myStrategy.check("daaaaa", 0, 2))
|
||||
Assert.assertSame(1, myStrategy.check("adaaaa", 1, 2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun failInTheMiddle() {
|
||||
Assert.assertSame(1, myStrategy.check("adbc", 0, 3))
|
||||
Assert.assertSame(4, myStrategy.check("cabcdcb", 1, 5))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun failOnTheLastSymbol() {
|
||||
Assert.assertSame(2, myStrategy.check("aad", 0, 3))
|
||||
Assert.assertSame(3, myStrategy.check("caadabd", 1, 4))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun successfulMatch() {
|
||||
Assert.assertSame(3, myStrategy.check("aca", 0, 3))
|
||||
Assert.assertSame(4, myStrategy.check("babcbda", 1, 4))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user