Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test that QgsRandomColorRamp returns distinct colors
  • Loading branch information
Mathias Rav authored and nyalldawson committed Aug 24, 2021
1 parent e8ba3f0 commit d260961
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/src/python/test_qgscolorramp.py
Expand Up @@ -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
Expand Down

0 comments on commit d260961

Please sign in to comment.