MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/noise_range.cpp:8–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "fl/stl/strstream.h"
7
8FL_TEST_FILE(FL_FILEPATH) {
9using namespace fl;
10
11FL_TEST_CASE("Noise Range Analysis") {
12 // Test 1D noise function
13 uint8_t min_1d = 255;
14 uint8_t max_1d = 0;
15
16 // Test representative range (optimized for speed while maintaining coverage)
17 for (uint32_t x = 0; x < 65536; x += 509) { // ~129 samples
18 uint8_t noise_val = inoise8(x);
19 if (noise_val < min_1d) min_1d = noise_val;
20 if (noise_val > max_1d) max_1d = noise_val;
21 }
22
23 // Test 2D noise function
24 uint8_t min_2d = 255;
25 uint8_t max_2d = 0;
26
27 for (uint16_t x = 0; x < 1024; x += 127) { // ~8x8 = 64 samples
28 for (uint16_t y = 0; y < 1024; y += 127) {
29 uint8_t noise_val = inoise8(x, y);
30 if (noise_val < min_2d) min_2d = noise_val;
31 if (noise_val > max_2d) max_2d = noise_val;
32 }
33 }
34
35 // Test 3D noise function
36 uint8_t min_3d = 255;
37 uint8_t max_3d = 0;
38
39 for (uint16_t x = 0; x < 256; x += 127) { // ~2x2x2 = 8 samples minimum
40 for (uint16_t y = 0; y < 256; y += 127) {
41 for (uint16_t z = 0; z < 256; z += 127) {
42 uint8_t noise_val = inoise8(x, y, z);
43 if (noise_val < min_3d) min_3d = noise_val;
44 if (noise_val > max_3d) max_3d = noise_val;
45 }
46 }
47 }
48
49 // Test raw noise functions for comparison
50 int8_t min_raw_1d = 127;
51 int8_t max_raw_1d = -128;
52
53 for (uint32_t x = 0; x < 65536; x += 509) {
54 int8_t raw_val = inoise8_raw(x);
55 if (raw_val < min_raw_1d) min_raw_1d = raw_val;
56 if (raw_val > max_raw_1d) max_raw_1d = raw_val;
57 }
58
59 int8_t min_raw_2d = 127;
60 int8_t max_raw_2d = -128;
61
62 for (uint16_t x = 0; x < 1024; x += 127) {
63 for (uint16_t y = 0; y < 1024; y += 127) {
64 int8_t raw_val = inoise8_raw(x, y);
65 if (raw_val < min_raw_2d) min_raw_2d = raw_val;

Callers

nothing calls this directly

Calls 2

inoise8Function · 0.85
inoise8_rawFunction · 0.85

Tested by

no test coverage detected