101-2-4

public void testFindLiveItemsLowerBoundAscending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in ascending order by x-value return DomainOrder.ASCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.1)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, 2.2)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {2.0, 2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, 2.2)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {2.0, 2.0, 2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.2)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {2.0, 2.0, 2.0, 2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 2.2)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.4)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, 5.5));
public void testFindLiveItemsUpperBoundAscending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in ascending order by x-value return DomainOrder.ASCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.1)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {2.0}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 2.2)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {2.0, 2.0}}); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {2.0, 2.0, 2.0}}); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {2.0, 2.0, 2.0, 2.0}}); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/junit/RendererUtilitiesTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/junit/RendererUtilitiesTests.java
Method name: `` |  | Method name: ``
Number of AST nodes: 0 |  | Number of AST nodes: 0

1

    public void testFindLiveItemsLowerBoundAscending() {↵

1

    public void testFindLiveItemsUpperBoundAscending() {↵

2

            DefaultXYDataset d = new DefaultXYDataset() {↵

2

            DefaultXYDataset d = new DefaultXYDataset() {↵

3

                public DomainOrder getDomainOrder() {↵

3

                public DomainOrder getDomainOrder() {↵

4

                    // we're doing this for testing only, and make sure that we ↵

4

                    // we're doing this for testing only, and make sure that we ↵

5

                    // only add data in ascending order by x-value↵

5

                    // only add data in ascending order by x-value↵

6

                    return DomainOrder.ASCENDING;↵

6

                    return DomainOrder.ASCENDING;↵

7

                }↵

7

                }↵

8

            };↵

8

            };↵

9

            // check a series with no items↵

9

            // check a series with no items↵

10

            d.addSeries("S1", new double[][] {{}, {}});↵

10

            d.addSeries("S1", new double[][] {{}, {}});↵

11

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, ↵

11

            assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, ↵

12

                    11.1));↵

12

                    11.1));↵

13

            ↵

13

            ↵

14

            // check a series with one item↵

14

            // check a series with one item↵

15

            d.addSeries("S2", new double[][] {{1.0}, {2.0}});↵

15

            d.addSeries("S2", new double[][] {{1.0}, {2.0}});↵

16

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, ↵

16

            assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, ↵

17

                    1.1));↵

17

                    1.1));↵

18

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, ↵

18

            assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, ↵

19

                    2.2));↵

19

                    2.2));↵

20

            ↵

20

            ↵

21

            // check a series with two items↵

21

            // check a series with two items↵

22

            d.addSeries("S3", new double[][] {{1.0, 2.0}, {2.0, 2.0}});↵

22

            d.addSeries("S3", new double[][] {{1.0, 2.0}, {2.0, 2.0}});↵

23

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, ↵

23

            assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, ↵

24

                    1.1));↵

24

                    1.0));↵

25

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, ↵

25

            assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, ↵

26

                    2.2));↵

26

                    2.2));↵

27

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, ↵

27

            assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, ↵

28

                    3.3));↵

28

                    3.3));↵

29

            assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, ↵

29

            assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, ↵

30

                    4.4));↵

30

                    4.4));↵

31

            ↵

31

            ↵

32

            // check a series with three items↵

32

            // check a series with three items↵

33

            d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {2.0, 2.0, 2.0}});↵

33

            d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {2.0, 2.0, 2.0}});↵

34

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, ↵

34

            assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, ↵

35

                    1.1));↵

35

                    1.1));↵

36

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, ↵

36

            assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, ↵

37

                    2.2));↵

37

                    2.2));↵

38

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, ↵

38

            assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, ↵

39

                    3.3));↵

39

                    3.3));↵

40

            assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, ↵

40

            assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, ↵

41

                    4.4));↵

41

                    4.4));↵

42

            ↵

42

            ↵

43

            // check a series with four items↵

43

            // check a series with four items↵

44

            d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {2.0, 2.0, ↵

44

            d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {2.0, 2.0, ↵

45

                    2.0, 2.0}});↵

45

                    2.0, 2.0}});↵

46

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, ↵

46

            assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, ↵

47

                    1.1));↵

47

                    1.1));↵

48

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, ↵

48

            assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, ↵

49

                    2.2));↵

49

                    2.2));↵

50

            assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, ↵

50

            assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, ↵

51

                    3.3));↵

51

                    3.3));↵

52

            assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, ↵

52

            assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, ↵

53

                    4.4));↵

53

                    4.4));↵

54

            assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, ↵

54

            assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, ↵

55

                    5.5));↵

55

                    5.5));↵

56

56

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 0
Number of refactorable cases | 0
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0
Clones location |
Number of node comparisons | 0