Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Sep 6, 2024
1 parent a67235f commit 9b6ca5c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,17 @@ function tempColor(badness: number): [number, number, number] {
let saturation = 1.0;
let lightness = 0.75;
try {
saturation = parseFloat(
const rSaturation = parseFloat(
SDFGRenderer.getCssProperty('--overlay-color-saturation')
);
lightness = parseFloat(
if (rSaturation !== undefined && !Number.isNaN(rSaturation))
saturation = rSaturation;

const rLightness = parseFloat(
SDFGRenderer.getCssProperty('--overlay-color-lightness')
);
if (rLightness !== undefined && !Number.isNaN(rLightness))
lightness = rLightness;
} catch (_ignored) {
// Ignored.
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils/collections.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { AccessStack, LinkedStack } from "../../../src/utils/collections";
import { AccessStack, LinkedStack } from '../../../src/utils/collections';

function testLinkedStackConstruction(): void {
const lStack = new LinkedStack();
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/utils/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { getTempColorHslString } from '../../../src';

function testTempColor(): void {
expect(getTempColorHslString(1.0)).toBe('hsl(0,100%,75%)');
expect(getTempColorHslString(0.0)).toBe('hsl(120,100%,75%)');
expect(getTempColorHslString(0.5)).toBe('hsl(60,100%,75%)');
}

describe('Test utility functions', () => {
test('Badness to temperature color conversion', testTempColor);
});

0 comments on commit 9b6ca5c

Please sign in to comment.