Skip to content
Permalink
Browse files
Test that QgsRandomColorRamp returns distinct colors
  • Loading branch information
Mathias Rav authored and nyalldawson committed Aug 24, 2021
1 parent e8ba3f0 commit d26096103618e02ebf8038b11fc1b2eb9da6dc2d
Showing with 7 additions and 4 deletions.
  1. +7 −4 tests/src/python/test_qgscolorramp.py
@@ -288,11 +288,14 @@ def testQgsRandomColorRamp(self):
self.assertEqual(cloned.type(), 'randomcolors')

# test with pregenerated colors
for i in range(10000):
r.setTotalColorCount(10)
for j in range(10):
c = r.color(j * 0.1)
for n in range(2, 100):
r.setTotalColorCount(n)
seen = set()
for j in range(n):
c = r.color(j / (n - 1))
self.assertTrue(c.isValid())
seen.add(c.rgb())
self.assertEqual(len(seen), n)

def testQgsPresetSchemeColorRamp(self):
# test preset color ramp

0 comments on commit d260961

Please sign in to comment.