|
| 1 | +# test.py |
| 2 | +from bashplotlib.scatterplot import _plot_scatter |
| 3 | +import unittest |
| 4 | + |
| 5 | +class TestScatterPlot(unittest.TestCase): |
| 6 | + def test_no_points(self): |
| 7 | + self.assertEqual(_plot_scatter([], [], 10, "x", |
| 8 | + "My Test Graph", "default", "My X Axis", "My Y Axis"), |
| 9 | + """ +------------------------+\n | My Test Graph | |
| 10 | + +------------------------+ |
| 11 | + +------------------------+ |
| 12 | +M | | | |
| 13 | +y | | | |
| 14 | + | | | |
| 15 | +Y | | | |
| 16 | + | | | |
| 17 | +A | - - - - - o - - - - - | |
| 18 | +x | | | |
| 19 | +i | | | |
| 20 | +s | | | |
| 21 | + | | | |
| 22 | + | | | |
| 23 | + +------------------------+ |
| 24 | + My X Axis""") |
| 25 | + |
| 26 | + def test_points(self): |
| 27 | + self.assertEqual(_plot_scatter([-10, -3, 20,30], [-10, 6, 20,-2], 10, "*", |
| 28 | + "Points!", "default", "Something x", "Another y"), |
| 29 | + """ +--------------------------+\n | Points! | |
| 30 | + +--------------------------+ |
| 31 | + +--------------------------+ |
| 32 | +A | | * | |
| 33 | +n | | | |
| 34 | +o | | | |
| 35 | +t | | | |
| 36 | +h | | | |
| 37 | +e | * | | |
| 38 | +r | | | |
| 39 | + | - - - o - - - - - - - - | |
| 40 | +y | | | |
| 41 | + | | * | |
| 42 | + | | | |
| 43 | + | * | | |
| 44 | + +--------------------------+ |
| 45 | + Something x""") |
| 46 | + |
| 47 | + def test_points_on_axes(self): |
| 48 | + self.assertEqual(_plot_scatter([0, -10, 0, 20,0], [0, 0, 6, 0,-2], 10, "#", |
| 49 | + "Points!", "default", "x", "y"), |
| 50 | + """ +--------------------------+\n | Points! | |
| 51 | + +--------------------------+ |
| 52 | + +--------------------------+ |
| 53 | +y | # | |
| 54 | + | | | |
| 55 | + | | | |
| 56 | + | | | |
| 57 | + | | | |
| 58 | + | | | |
| 59 | + | | | |
| 60 | + | | | |
| 61 | + | # - - - # - - - - - - # | |
| 62 | + | | | |
| 63 | + | | | |
| 64 | + | # | |
| 65 | + +--------------------------+ |
| 66 | + x""") |
| 67 | + |
| 68 | +if __name__ == "__main__": |
| 69 | + unittest.main() |
0 commit comments