spin Marker Callibration
This commit is contained in:
46
test/spinNormalize.test.js
Normal file
46
test/spinNormalize.test.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* spinNormalize.test.js
|
||||
* Unit-Tests für server/spinNormalize.cjs
|
||||
*
|
||||
* Sichert ab, dass der Spin-Normalisierer alle Randfälle korrekt behandelt,
|
||||
* insbesondere negative Werte (z.B. 0 − 90 = −90 → 270).
|
||||
*/
|
||||
|
||||
const { normalizeSpinDeg } = require('../server/spinNormalize.cjs');
|
||||
|
||||
describe('normalizeSpinDeg', () => {
|
||||
test('Standardwerte 0 / 90 / 180 / 270 bleiben unverändert', () => {
|
||||
expect(normalizeSpinDeg(0)).toBe(0);
|
||||
expect(normalizeSpinDeg(90)).toBe(90);
|
||||
expect(normalizeSpinDeg(180)).toBe(180);
|
||||
expect(normalizeSpinDeg(270)).toBe(270);
|
||||
});
|
||||
|
||||
test('Wert 360 wird auf 0 normalisiert', () => {
|
||||
expect(normalizeSpinDeg(360)).toBe(0);
|
||||
expect(normalizeSpinDeg(720)).toBe(0);
|
||||
expect(normalizeSpinDeg(450)).toBe(90);
|
||||
});
|
||||
|
||||
test('Negative Werte werden korrekt umgerechnet', () => {
|
||||
expect(normalizeSpinDeg(-90)).toBe(270); // 0 − 90 → 270
|
||||
expect(normalizeSpinDeg(-180)).toBe(180);
|
||||
expect(normalizeSpinDeg(-270)).toBe(90);
|
||||
expect(normalizeSpinDeg(-360)).toBe(0);
|
||||
expect(normalizeSpinDeg(-1)).toBe(359);
|
||||
});
|
||||
|
||||
test('Strings werden als Zahlen interpretiert', () => {
|
||||
expect(normalizeSpinDeg('90')).toBe(90);
|
||||
expect(normalizeSpinDeg('-90')).toBe(270);
|
||||
});
|
||||
|
||||
test('Ergebnis liegt immer in [0, 360)', () => {
|
||||
const inputs = [-720, -359, -1, 0, 1, 89, 90, 179, 270, 359, 360, 450, 720, 1080];
|
||||
for (const v of inputs) {
|
||||
const r = normalizeSpinDeg(v);
|
||||
expect(r).toBeGreaterThanOrEqual(0);
|
||||
expect(r).toBeLessThan(360);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user